DLookup

J

johnlute

Access 2003

I posted this at the tail end of an earlier thread but since it's
about a very different issue I thought it made sense to post it here.

I've tossed in a DLookup into the following:

If fOSUserName = DLookup("txtUserName", "tblUserNames") Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry! You are not allowed to use this form.",
vbCritical, vbOKOnly
DoCmd.CancelEvent
End If

This won't work UNLESS the table being looked up only has ONE user
name recorded. If I add more than one user name to the table then I
get the "not allowed" error message.

This isn't what I expect from DLookup - or am I way off base...?

Thanks!
 
D

Dirk Goldgar

johnlute said:
Access 2003

I posted this at the tail end of an earlier thread but since it's
about a very different issue I thought it made sense to post it here.

I've tossed in a DLookup into the following:

If fOSUserName = DLookup("txtUserName", "tblUserNames") Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry! You are not allowed to use this form.",
vbCritical, vbOKOnly
DoCmd.CancelEvent
End If

This won't work UNLESS the table being looked up only has ONE user
name recorded. If I add more than one user name to the table then I
get the "not allowed" error message.

This isn't what I expect from DLookup - or am I way off base...?

Thanks!


Does my reply in the other thread clarify it for you? If you give no
criteria to DLookup, it just looks at the first (abritrarily selected)
record in the table.
 
J

johnlute

Hi, Dirk.

Your response to the other thread was entirely helpful - thanks! I
posted this one in an attempt to keep the other thread from getting
messy - but I think I've made a mess, anyway!

Thanks!

Please disregard this thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top