Beginners question. I'm just learning VBA for Access and I'm having an issue setting a field value to a variable. See code below.
I can get the value of the field I click on (ORDERNO) and even display it in a msgbox. But I cannot get it assigned to a variable. When I run the below code I get an Object Require error highlighting the Set orderNum line.
I've tried the following for that line.
Code:
Set orderNum = myF![ORDERNO].Value
and
Set orderNum = Str(myF![ORDERNO])
What's the obvious error that my inexperience cannot see?
Thx
Code:
Private Sub ORDERNO_Click()
Dim myF As Form, orderNum As String, whereCnd As String
Set myF = Forms("frmSalesOrderList")
'MsgBox myF![ORDERNO]
Set orderNum = myF![ORDERNO]
Set whereCnd = "[ORDERNO] = " & orderNum
MsgBox whereCnd
'docmd.OpenForm(frmSalesOrderInfo,acNormal,,whereCnd,,,)
End Sub