469,898 Members | 1,779 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Runtime error 2001

I am getting this error when running a module in Access 2002...anyone
know what it is? and how to correct it?
Nov 13 '05 #1
5 32437
Many causes. What line is giving the error?

Examples:
- 3rd argument for DLookup() is malformed.
- Filter string for a form is mal-formed.
- Something necessitated saving the record in the form, and the save failed,
so the thing you asked for can't happen either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kildareguy" <ke****@eircom.net> wrote in message
news:f6**************************@posting.google.c om...
I am getting this error when running a module in Access 2002...anyone
know what it is? and how to correct it?

Nov 13 '05 #2
Allen, Thanks, but am still having problems. The code is below:- Can you help?

Karl

Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Q1
Dim Q2
'Variable definition section
Username = InputBox( _
"You're using the error database" & _
Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & _
Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Qresult1 = DLookup("[Username]", "LogOn", "[Username] = username")
qresult2 = DLookup("[Password]", "Logon", "[Password] = password")
'Processing logic section
If Username = Q1 And Password = Q2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
Many causes. What line is giving the error?

Examples:
- 3rd argument for DLookup() is malformed.
- Filter string for a form is mal-formed.
- Something necessitated saving the record in the form, and the save failed,
so the thing you asked for can't happen either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kildareguy" <ke****@eircom.net> wrote in message
news:f6**************************@posting.google.c om...
I am getting this error when running a module in Access 2002...anyone
know what it is? and how to correct it?

Nov 13 '05 #3
The 3rd argument of DLookup() is not formed correctly.

Concatenate the value of the string variable into the string, surrounded by
quotes:
Qresult1 = DLookup("[Username]", "LogOn", "[Username] = """ & username &
"""")

For more help on how to build the arguments for DLookup(), see:
http://members.iinet.net.au/~allenbrowne/casu-07.html
BTW, instead of using 2 input boxes, you might like to create a little
unbound form with 2 text boxes, and a command button to make it go. If you
set the Input Mask of the 2nd text box to:
Password
I think you will like the way it looks when the user enters their password.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"karl" <km******@eircom.net> wrote in message
news:90**************************@posting.google.c om...
Allen, Thanks, but am still having problems. The code is below:- Can you
help?

Karl

Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Q1
Dim Q2
'Variable definition section
Username = InputBox( _
"You're using the error database" & _
Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & _
Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Qresult1 = DLookup("[Username]", "LogOn", "[Username] = username")
qresult2 = DLookup("[Password]", "Logon", "[Password] = password")
'Processing logic section
If Username = Q1 And Password = Q2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
Many causes. What line is giving the error?

Examples:
- 3rd argument for DLookup() is malformed.
- Filter string for a form is mal-formed.
- Something necessitated saving the record in the form, and the save
failed,
so the thing you asked for can't happen either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kildareguy" <ke****@eircom.net> wrote in message
news:f6**************************@posting.google.c om...
>I am getting this error when running a module in Access 2002...anyone
> know what it is? and how to correct it?

Nov 13 '05 #4
km******@eircom.net (karl) wrote in message news:<90**************************@posting.google. com>...
I am getting the error on the 1st LOOKUP line...Q1 =
DLookup("[Username]", "LogOn", "[Username] = username")

Any suggestions?

Karl



Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Q1
Dim Q2
'Variable definition section
Username = InputBox( _
"You're using the error database" & _
Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & _
Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Q1 = DLookup("[Username]", "LogOn", "[Username] = username")
Q2 = DLookup("[Password]", "Logon", "[Password] = password")
'Processing logic section
If Username = Q1 And Password = Q2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
Many causes. What line is giving the error?

Examples:
- 3rd argument for DLookup() is malformed.
- Filter string for a form is mal-formed.
- Something necessitated saving the record in the form, and the save failed,
so the thing you asked for can't happen either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kildareguy" <ke****@eircom.net> wrote in message
news:f6**************************@posting.google.c om...
I am getting this error when running a module in Access 2002...anyone
know what it is? and how to correct it?

Nov 13 '05 #5
Two problems. The first is that your variable username must be outside of
the quotes in order for the DLookup to get the value that's in the variable.
The second is that values for text fields must be enclosed in quotes.

Q1 = DLookup("[Username]", "LogOn", "[Username] = " & Chr$(34) & username &
Chr$(34))
Q2 = DLookup("[Password]", "Logon", "[Password] = " & Chr$(34) & password
& Chr$(34))

(Chr$(34) is ")

There might be a possible 3rd problem: username and password may be reserved
words, so if you're still having problems, you might want to rename them.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"karl" <km******@eircom.net> wrote in message
news:90**************************@posting.google.c om...
km******@eircom.net (karl) wrote in message news:<90**************************@posting.google. com>... I am getting the error on the 1st LOOKUP line...Q1 =
DLookup("[Username]", "LogOn", "[Username] = username")

Any suggestions?

Karl



Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Q1
Dim Q2
'Variable definition section
Username = InputBox( _
"You're using the error database" & _
Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & _
Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Q1 = DLookup("[Username]", "LogOn", "[Username] = username")
Q2 = DLookup("[Password]", "Logon", "[Password] = password")
'Processing logic section
If Username = Q1 And Password = Q2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
Many causes. What line is giving the error?

Examples:
- 3rd argument for DLookup() is malformed.
- Filter string for a form is mal-formed.
- Something necessitated saving the record in the form, and the save failed, so the thing you asked for can't happen either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kildareguy" <ke****@eircom.net> wrote in message
news:f6**************************@posting.google.c om...
>I am getting this error when running a module in Access 2002...anyone
> know what it is? and how to correct it?

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Adam Smith | last post: by
6 posts views Thread by Peter Frost | last post: by
7 posts views Thread by Jorgen Haukland, Norway | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.