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

How do I Sync a Main by clicking a record on a subform

Form Basics

How do I Sync a Main by clicking a record on a subform

by  DougP  Posted    (Edited  )
Here is a picture to look at
http://www.barcodeone.com/winsoft/images/FindItFAST.jpg

In order for this to work you CANNOT have any Primary keys on the table where the main form is connected to.

In the subform's On_click event put this code

Private Sub Form_Click()
Dim SyncCriteria As String
Dim f As Form, rs As Recordset

'Define the from object and recordset object for the AutoCAD form
Set f = Forms(Screen.ActiveForm.FormName)
Set rs = f.RecordsetClone

' define the criteria used for the sync
SyncCriteria = "[stock_code]='" & Me![STOCK_CODE] & "'"

' find the corresponding record in the Parts table
rs.FindFirst SyncCriteria
f.Bookmark = rs.Bookmark
End Sub

Now view the form like normal, click in the far left gray square on the subform (look at sample picture above) these gray squares are the ones with the black arrow in it.
The main form will jump to the record on the subform.

That's it.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top