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

Go to record in subform using onclink event in another suform

Status
Not open for further replies.

Astrofax

Technical User
Aug 30, 2003
6
0
0
GB
I’m using Access 2K on XP Professional with reference to DAO 2.5/3.5 Compatibility library

I have been trying to find a way to go to a record on one subform with a button click from a subform, nested within it

There is a main form with company details, subfrom A with employee contact details and subform B, nested in subform A, which shows all the contacts for the company.

What I would like to do is to either set up the onclick event for the contacts name or a button that goes to the employees details in subfrom A.

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "subformA"

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

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub

I have used the wizard to open a form and goto the record that matches the contactID record selected in sub form B and have edited it to reflect mainform, subforms A & B etc, but have been unable to get it to work.

Any thoughts would be useful. I haven’t done a lot of coding in Access and tend to edit code created by wizards.

Regards

Philip
 
In the click event for one or more of the fields for subform B put:

Me.Parent.recordset.Bookmark = Me.recordset.Bookmark
 
Thanks for that lupins. I followed up on your piece of code and ended up using...

Me.Parent.Recordset.FindFirst "contactID=" & Me.contactID

...which worked fine, but is this the best and correct way?

Regards

Philip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top