Form Navigation

17PSI

New member
Local time
, 19:39
Joined
Nov 1, 2001
Messages
6
I wanted to get some advice on form navigation. Here is a very basic summary of my db. I have parent, child, and accounting tables, and each has a form for data entry. The Parent table has ParentID as Auto number for the primary key, the Child table has childID as Auto number for the primary key and ParentID as the foreign key, and Accounting has accountingID as Auto number for the primary key and childID as the foreign key. There are relationships setup: Parent->Child->Accounting. What I would like to know is what the best way to setup my forms. The first form the user will fill in will be the parent form, from there the child form and finally the accounting form. What I would like to do is have the user fill in the parent form, Click an Add Child button, upon clicking the button it should open the Child form (new record) and establish a relationship from the ParentID. I would prefer not to use sub forms.

Thanks for the help!!
 
If it is acceptable to have the Parentform open during the process, I think you can use something like this:

Dim strParentKey as string

strParentKey = me.ParentID

Docmd.openform "childform",,,,acformadd

me.ParentID = strParentKey
(maybe Forms!childform.ParentID = strParentID)

Fuga.
 
Last edited:
Thanks for the reply Fuga; I would however prefer that the Parent form be closed. Also, in regards to my initial question is this most logical approach I should take or should I approach this from another angle.

Thanks
 
Fuga's solution should work. If you want to close the Parent form, try inserting a docmd.close statement after the child form has been opened and the parent id value inserted.

Docmd.openform "childform",,,,acformadd

forms!childform.parentID = me.parentID

Docmd.close


I'm not sure if this will work properly as I haven't tried it, but it should open the child form, assign the value for the parentID from the Parent form to the childform's Parent ID field and then close the Parentform. You may have to add something after the DoCmd.close statement to tell it which form to close, but I believe it will work this way.

HTH:)
 
Use the where argument of the OpenForm method to sync the forms and open the second form in normal mode rather than add mode so you can see any existing records.
 

Users who are viewing this thread

Back
Top Bottom