common field used to link multiple forms to a main form

JKK

Registered User.
Local time
Tomorrow, 01:21
Joined
May 4, 2011
Messages
19
Hey guys,

I have a form (for reference purposes call it "frmMain") on which I have placed various buttons; each linking to another form.

My main form has a Payments button linking to a Payments form and a Meetings button linking to a Meetings form.

On my main form I have 3 subforms (not sure if this is relevant or not). Each time I select a Company (from a combobox), the subforms are populated with the relevant data relating to that specific CompanyID field.

I want the same thing to happen to these other forms (the Payments and Meetings forms). In other words, when a company is selected and I click on the Payments button, that form should be populated with the relevant info; and if there is no info for that company, when I enter it into the form it should save it alongside the relevant CompanyID field in the Payments table.

At the moment, when I click on the Payments button I am directed to the Payments form. After entering info into the form, all data is stored in the table, but the CompanyID field is left blank.

I look forward to hearing your advise and finally solving this issue:)
 
If you are using a Button_Click() Event Procedure like:

Code:
Private Sub Command4_Click()
DoCmd.OpenForm "Payments", acNormal
End Sub

to open the Payments Form then you may modify this statement to pass the CompanyID from frmMain as an Open Argument value (OpenArgs) like:

Code:
Private Sub Command4_Click()
DoCmd.OpenForm "Payments", acNormal, , , , , Me![CompanyID]
End Sub

On the Payment Form's Form_Load() Event procedure you can read this information back and insert it into the CompanyID field like:

Code:
Private Sub Form_Load()
Me![CompanyID] = Me.OpenArgs
End Sub

You may use the same method for other forms too.
 
Amazing! Thank you, that's been bugging me for days!
 

Users who are viewing this thread

Back
Top Bottom