VB Code Error

VB Code Error

Post by JObrie » Fri, 07 Nov 2003 06:33:09


This command

varX = DLookup("[password]","[Users]","[Username]
= "&Forms!session!UserID)

produces this error

The expression you entered in a query parameter produced
this error: "the object doesn't contain the automation
object 'Obrien'"

UserID was Obrien.

We're trying to simulate a password entry screen into a
change form and trying to validate password entry.

Any assistance is much appreciated.
 
 
 

VB Code Error

Post by Andrew Smi » Fri, 07 Nov 2003 06:40:33

You need to enclose the UserID in quotes as it is a string, otherwise it
will be interpreted as a variable name. The usual method is to use
apostrophes:

varX = DLookup("[password]","[Users]","[Username] = '"&
Forms!session!UserID & "'")

However you'll need something a bit cleverer than this if your usernames can
contain apostrophes or other special characters (eg if you might have a user
called O'Brien then this won't work). If your user names don't contain any
special characters then this method will work fine.

 
 
 

VB Code Error

Post by MV » Sat, 08 Nov 2003 10:01:26

Try the following. It should work UNLESS Forms!Session!UserID contains a
quotation mark - apostrophes are not a problem.

VarX = DLookup("[password]","[Users]",
"[Username] = " & Chr(34) & Forms!session!UserID &Chr(34))

(All on one line)