I getting a run time error 2185
, "You can't reference a property or method for a control unless the control has the focus ...".
This is my code that I am using.
Private Sub Command5_Click()
Dim cardno As Integer
cardno = cardnumber.Text
DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number]
End Sub
Referencing the .Text
property of a control requires it to have focus.
Simply drop that and it should work (the default is .Value
)
OR
Try putting in the SetFocus method as advised by Access, i.e.
Private Sub Command5_Click()
Dim cardno As Integer
cardnumber.SetFocus <-------Use this line to set the focus
cardno = cardnumber.Text
DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number]
End Sub
That run time error means You can't reference a property or method for a control unless the control has the focus.
You can use .Text
when a control has the focus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With