DLookup Syntax Help for Ken Snell

DLookup Syntax Help for Ken Snell

Post by Dan » Sat, 31 Jul 2004 02:58:00


Hi Ken:

Thank you but is still giving me this message:

Application can't find the field '|' referred to in your
expression

Thaks,

Dan
message

in a
 
 
 

DLookup Syntax Help for Ken Snell

Post by Ken Snel » Sat, 31 Jul 2004 08:19:28

Assuming that UserID is a text-formatted field in your table pswc, try this:

If IsNull(DLookup("UserID", "pswc", _
"[UserID]='" & [UserID] & "'")) = False Then
DoCmd.OpenForm stDocName, , , stLinkCriteria


If it's a numeric-formatted field:

If IsNull(DLookup("UserID", "pswc", _
"[UserID]=" & [UserID])) = False Then
DoCmd.OpenForm stDocName, , , stLinkCriteria


I probably would use the DCount function in this situation though, instead
of DLookup, as you know a specific value that you want to test for (again
assuming text-formatted field):

If DCount("*", "pswc", "[UserID]='" & [UserID] & "'")) > 0 Then
DoCmd.OpenForm stDocName, , , stLinkCriteria

--

Ken Snell
<MS ACCESS MVP>

 
 
 

DLookup Syntax Help for Ken Snell

Post by Dan » Sat, 31 Jul 2004 08:42:07

Hi Ken:

It is just a simple table with a userid field (text); if
dlookup finds this name then open the data entry form...

everything is text but , I have no clue, why I get the
message:field '|' not found...

thanks,

Dan
table pswc, try this:
situation though, instead
test for (again
0 Then
message
 
 
 

DLookup Syntax Help for Ken Snell

Post by Ken Snel » Sat, 31 Jul 2004 09:52:34

Are you sure that you have a control or field named UserID on the form that
is running this code? Post the SQL of the form's RecordSource query.
--

Ken Snell
<MS ACCESS MVP>