Variable not defined in a recordset

J

Joanne

Hello, Can anyone tell me why tblusers is being seen as a variable here? It
keeps saying "variable not defined".

Thank you very much (I'm still pretty much a newbie)

If rs.Fields("Floor").Value = "" And tblUsers.LoginID =
Form_frmComputers.Computer_Name Then
MsgBox "Please enter a Floor Value"
txtRoom.Enabled = True
End If
 
M

Marshall Barton

Joanne said:
Hello, Can anyone tell me why tblusers is being seen as a variable here? It
keeps saying "variable not defined".

Thank you very much (I'm still pretty much a newbie)

If rs.Fields("Floor").Value = "" And tblUsers.LoginID =
Form_frmComputers.Computer_Name Then
MsgBox "Please enter a Floor Value"
txtRoom.Enabled = True
End If


Table and field names are only known in queries. If you
open a recordset, the recordset object will make the fields
in its table/query available through its Fields collection.

I don't understand what you are trying to do here, but you
may be able to use the DLookup function to get the value
from the table. Possibly as simple as
. . . And DLookup("LoginID", "tblUsers") = _
Me.Computer_Name Then
or, if frmComputers is a different form,
. . . And DLookup("LoginID", "tblUsers") = _
Forms!frmComputers.Computer_Name Then
 
Top