open all forms and synch data

robart6

Registered User.
Local time
Today, 17:16
Joined
Feb 11, 2004
Messages
19
When my Main Form opens I want all other forms to open as hidden - - need code. Can be one line for each form or inclusive (if such a thing exists).

Also, Main Form has a combo box. When value is selected in this combo box, I want all open forms to find the record corresponding to this selection. Once again, need code.

I will then show the hidden form depending on which command button the user has clicked. This I know how to do.

Please help; I'm driving myself nuts with this.
 
Sorry if I have misread your post but why are you storing data in multiple tables or are you pulling the data through queries which the forms are based?

If so why would you pull the data that matches the combo selection then show all of the forms that apply. Why not create a query that references the combo value.

code for hidden forms is:
Code:
docmd.openform "formname",,,,achidden

Andy
 
Thanks for the reply, Andy.

All the forms are based on tables which have relationships based on Person ID. Ex: TblPersons contains Persons name, address, phone, etc and has an autonumber field named PersonID. TblAnimals contains Animals name, breed, color, etc. TblPersons has a one-to-many relationship to tblAnimals based on PersonID. TblComplaints contains complaint information and has a one-to-many relationship to tblPersons based on PersonID. When the user selects an entry from the combo box on the Main Form, I want to unhide frmPersons showing the corresponding record. FrmPersons has command buttons for each of the other forms. When the user clicks the Animals command button, I want to unhide frmAnimals showing the record that corresponds with PersonID. Likewise, if the user clicks the Complaints command button, I want to unhide frmComplaints showing the record that corresponds with PersonID.

Can this be accomplished with a statement in the form’s record source? Or with code in the AfterUpdate of the combo box? Or any other suggestions?

Your help is greatly appreciated.
 
Hi,

without actually looking at the forms, I would suggest that there is no need to open all of your forms at once and hide them as you can open them at the specific record at runtime by using the following code:

Code:
Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmAnimals"  'Form Name here
    stLinkCriteria = "[PersonID]=" & Me![PersonID]  ' ID  Name Goes Here
DoCmd.OpenForm stDocName, , , stLinkCriteria

This code would open the form frmAnimals at the record that relates to your Persons form ID.
This can be triggerred by command button.

As far as your combo you could use the code above but just change the personID to reflect the combo value.

If this doesn't work then if you can post a sample of the forms used, as it is always better to work on it in front of you.

Hope this helps

Andy
 
Andy, forgive me for not replying sooner - - have been out of town for a while.

I used the code you provided triggered by a command button and also used it with the combo box as you suggested; meets my needs perfectly. Thanks for all your help.
 

Users who are viewing this thread

Back
Top Bottom