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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronizing 2 different subforms

Status
Not open for further replies.

steveo33

Technical User
Jul 12, 2003
2
AU
I have two subforms on a MainForm. Subform1 has a record source (tblOne) containing N records, and subform2 has a record source (tblTwo) containing 2N records. There is no other relationship between the record sources. What I want to do is when you move to, say, record 2 on subform1, then subform2 will automatically move to its record 3. When you move to record 3 on subform1, then subform2 automatically moves to its record 5, and so on. (The relationship is: move to record J on subform1, and subform2 automatically updates to record (2*J-1)). I want it to work the same if you were navigating subform2 - move to record 3, and subform1 displays its record 2, etc. I have tried for a week but canot find the right vba code to synchronize the two subforms as described. Any help much appreciated.
 
Hi,

Your description does not tie in with your formula.

If Subform1 is record 1 then J = 1:

Subform2 record = 2 * J - 1 = 2 * 0 = 0

Please give 3 examples of Subform1 record number, along with related Subform2 record number.

(Include subform1 record 1 please).

Also, it's obvious that Subform2 can never have a record 1, is this what you want?

Also include a quick description of the data that you are processing.

Regards,

Darrylle


"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
.

"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Add the next codes into your Subforms & Try

Subform1:
Private Sub Form_Current()
On Error Resume Next
If Me.Parent.ActiveControl.Name = Me.Name Then
Me.Parent.subform2.Form.Recordset.Move Me.CurrentRecord * 2 - 1 - Me.Parent.subform2.Form.CurrentRecord
End If
End Sub

Subform2
Private Sub Form_Current()
On Error Resume Next
If Me.Parent.ActiveControl.Name = Me.Name Then
Me.Parent.Subform1.Form.Recordset.Move (Me.CurrentRecord + 1) \ 2 - Me.Parent.Subform1.Form.CurrentRecord
End If
End Sub

 
Thankyou very much. That is the answer. Works exactly how I want!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top