Solved Code for a button in the main form (1 Viewer)

Alex Motilal

New member
Local time
Tomorrow, 04:20
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:50
Joined
May 7, 2009
Messages
19,169
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
 

Alex Motilal

New member
Local time
Tomorrow, 04:20
Joined
Jul 7, 2021
Messages
15
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

Top Bottom