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

Alex Motilal

New member
Local time
Today, 05:33
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
Today, 08:03
Joined
May 7, 2009
Messages
16,394
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
Today, 05:33
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