Solved Code for a button in the main form

Alex Motilal

New member
Local time
Tomorrow, 00:11
Joined
Jul 7, 2021
Messages
15
Hello experts,
I do have a Main form with a continuous SubForm. When the button on the main form is clicked, another form should open based on the record selected in the SubForm.
I need the code for that.
Thanks
Alex
 
on the Click Event of your button add code:

Private Sub button1_Click()
DoCmd.OpenForm FormName:="theNameOfFormToOpen",WhereCondition:="[PKFieldName] = " & Me![SubformName].Form![PKTextboxName]
End Sub
 
on the Click Event of your button add code:

Private Sub button1_Click()
DoCmd.OpenForm FormName:="theNameOfFormToOpen",WhereCondition:="[PKFieldName] = " & Me![SubformName].Form![PKTextboxName]
End Sub
Thank you. However, it is showing Run time error 2465.
 

Users who are viewing this thread

Back
Top Bottom