Ask Your Question
0

Problems with OpenFormAtRecord() extra question

asked 2018-02-12 19:56:19 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

First, I am quite a beginner in macros.

I copied and edited meakasteve's Listing A. It worked fine but: In my case the relationship between tables is opposite. (TableA contais Properties and TableB Owners.) There can not be TableA_ID in TableB. Then, TableB opens only to the Record(0).

In the FormA there is a MainForm_Grid where I can choose a row (a Property). In the row exist both indexes, RowInA_ID and corresponding RowInB_ID (a Owner).

I have succesfully put both indexes in Global, but can not use them correctly to open the right form of record (that particular Owner). Should be simpel, but not for me, yet.

Listing A is found in question: Problems with OpenFormAtRecord()

Many thanks in advance for help. --vmjpak--

edit retag flag offensive close merge delete

Comments

@vmjpak Please do not post as Wiki - it helps no one.

Before actually posting your question, please look at preview. Your question all ran together & was extremely difficult to read. A return here & there makes it easier to read.

Whenever referring to another question please include a link to that question so it may be found easily by the reader. Your question is next to meaningless without the reference.

Ratslinger gravatar imageRatslinger ( 2018-02-12 21:34:25 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2018-02-12 22:07:03 +0200

Ratslinger gravatar image

updated 2018-02-12 22:24:51 +0200

Hello @vmjpak,

The referred to code (posted here) was actually copied from a working example in a previous question (found here)

Your stated relationship is not actually opposite. It is a relationship.

The process is actually very simple. On original form you have a record which contains the key of a record you wish to retrieve. This is what is needed in the Global variable. Next you change forms. On the new form, OpenFormAtRecord() macro is initiated from the forms Open Document event. This macro uses the saved global variable to open the form at the appropriate record.

Now each person using this method has different records, forms, reasons and wanted results than what is in the original sample. That is also why the second post was made - another different result was wanted. Modifications are typically needed. No one size fits all.

The most likely cause of your problem is not saving the correct ID in the first form. Only the ID for Owner is needed. This is what is supposedly wanted to be opened on the second form.

If you, after viewing this answer & the original sample, are still having problems, you will need to post a sample of what you have (no personal or confidential info) along with a better explanation of what is desired as a result.

If this answers your question please tick the ✔ (upper left area of answer). It helps others to know there was an accepted answer.

edit flag offensive delete link more

Comments

Had another thought. Since you have not provided any information on your form set-up, it may be your second form uses a table control (among many other possibilities). If so, much of the code in the macro needs to be modified. See the mentioned sample for the form the macro was written to work with.

Ratslinger gravatar imageRatslinger ( 2018-02-13 01:20:26 +0200 )edit

Success! So simple but almost impossible for the beginner. Bigger problems were: 1. Learn how to find to the Open Document event and access macro to the right place . 2. Reload: I had to change the line --> oForm.Reload(iOwnerID) (after too many tries&errors and Print tests) 3. The language of my LibreOffice is finnish and I have had big difficulties with the terms. Thanks very much Ratslinger. Maybe I have learnt something. --vmjpak, 75years--

vmjpak gravatar imagevmjpak ( 2018-02-14 12:06:20 +0200 )edit

@vmjpak When dealing with macros, the level of information needed increases exponentially. For more information and links to tools & documentation please refer to this post.

Ratslinger gravatar imageRatslinger ( 2018-02-14 16:34:02 +0200 )edit
0

answered 2018-02-14 12:06:49 +0200

vmjpak gravatar image

I edited the macro of meakasteve as follows: ( REM "OWNER" is TableB, just the opposite as meakasteve's "CUSTOMERS") 1. Global iOwnerID as Object 2.Sub GetID() : CustID > OwnerID, "CUSTDATA" > "OWNER" 3.Sub FormChange( sFormName) : No changes 4.Sub OpenFormAtRecord() : iCustID > iOwnerID, CUSTID > OWNERID and last break-through: I added OwnerID between parenthesis on Reload-line: oForm.Reload(OwnerID) --vmjpak--

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-12 19:56:19 +0200

Seen: 33 times

Last updated: Feb 14