Solved Open customers details form when I double click on their CustomerID (1 Viewer)

NatAccessNewbie

New member
Local time
Today, 20:09
Joined
Jan 25, 2022
Messages
13
Hello
I want to be able to open a customers details by double clicking on their CustomerID from my Ongoing Orders Subform.

I've tried the code below which opens up the correct form but doesn't open to the relating customer that I clicked on. How do I define which customer's record needs to be displayed? TIA :)


Private Sub CustomerID_DblClick(Cancel As Integer)

DoCmd.OpenForm "CustomerDetailsF"

End Sub
 

jdraw

Super Moderator
Staff member
Local time
Today, 15:09
Joined
Jan 23, 2006
Messages
15,379
I would think you would have to supply the appropriate CustomerID as part of the OpenArgs to the
DoCmd.OpenForm "CustomerDetailsF"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:09
Joined
May 7, 2009
Messages
19,229
you can also use the WhereCondition parameter of the DoCmd.OpenForm method.
 

sonic8

AWF VIP
Local time
Today, 21:09
Joined
Oct 27, 2015
Messages
998
Assuming the corresponding column in the Recordsource of your form is also named CustomerID:
Code:
Private Sub CustomerID_DblClick(Cancel As Integer)
    DoCmd.OpenForm "CustomerDetailsF",,,"CustomerID=" & me.CustomerID.Value
End Sub
 

NatAccessNewbie

New member
Local time
Today, 20:09
Joined
Jan 25, 2022
Messages
13
Assuming the corresponding column in the Recordsource of your form is also named CustomerID:
Code:
Private Sub CustomerID_DblClick(Cancel As Integer)
    DoCmd.OpenForm "CustomerDetailsF",,,"CustomerID=" & me.CustomerID.Value
End Sub

That works perfectly! thank you so much :)
 

Users who are viewing this thread

Top Bottom