runtime error '2001'

M

michael goodall

i am trying to run a piece of code that i know works to look up the
value of a query stored in a table, but when i try to run it, i get a
runtime error 2001 message. can anyone help me? the code i am using
is: If Nz(DLookup("admingroup", "group"), 0) = 2 Then DoCmd.OpenForm
"loginsuccessful" else msgbox "error". any assistance will be greatly
appreciated. michael
 
G

Guest

The following works for me:

Public Function fPickForm()
If Nz(DLookup("Index_Group", "A"), 0) = 2 Then
DoCmd.OpenForm "ASA"
Else: MsgBox "error"
End If
End Function

I noticed that you don't have an End If. Could that be the problem?

Have you compiled the code?

What happens when you run the following in the Immediate window?

Nz(DLookup("admingroup", "group"), 0)

Nz(DLookup("admingroup", "group"), 0) = 2
 
A

Allen Browne

You can get this error if one of the names is wrong, e.g. if the field is
actually called [admin group] with a space.

Try adding square brackets around the table name as well, i.e. [group]
Group is a reserved word in JET SQL, so it might cause problems.
For a check list of words to avoid, see:
http://allenbrowne.com/AppIssueBadWord.html
 

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

Similar Threads


Top