Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronize Two Forms

Status
Not open for further replies.

nubianqueen

Technical User
Apr 16, 2002
19
US
Hey Guys
I'm sure this question has been asked before, but I've been looking through previous messages and I haven't found a answer yet.
I have two forms, Form1 and Form2. Form1 is from the one side and Form2 is the many side. I have a command button on Form1 to open Form2. Primary Key is "ComplaintID".
I want to make sure when Form2 opens it is in sync with current record open on Form1.
How do I right the code and where should it go, on Form1 or Form2?

Thanks in Advance
 
Often the simplest way is to set the recordsource for form 2 so that the recordsource is set to a query, something like

Table.* (selects all fields - you can select just the ones you need)
Table.ComplainID, Criteria= "form1!ComplaintID"

Also make sure that you cant add new record with the form, and that tab keeps you within the record.

If you want to open form2 when form1 has a new record, you will have to save the record on form1 first.


Oh, and refresh form1 when you close or deactivate form2 so that the record locking does not stop you editing it.

 
An alternative to SeeThru's solution would be to open form 2 with a 'where' condition on the button's click event the code wopuld look something like this:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"

stLinkCriteria = "[ComplaintID]=" & "'" & Me![ComplaintID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

The button wizard will create this code for you.

Another alternative would be to have Form2 as a subform of form 1.

HTH
Lead Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top