Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2006, 12:43 AM
Authorized User
Join Date: May 2006
Location: Elk Grove, CA, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run-time error 2001

I have created a table of users and password for a login table.
I have created a form using the table fields username and password.
When I go to login the I am getting a runtime error to debug.
When I go to debug it is coming up with this line highlighted.
If Me.Password.Value = DLookup("Password", "Contacts", "[UserID] =" & Me.UserID.value) Then
I am not sure what is wrong.
Can anyone assist me?

Reply With Quote
  #2 (permalink)  
Old June 8th, 2006, 06:56 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

I am not sure since I do this a different way.

What I would suggest is to take the PK this way and insert it into the SQL statement as a variable.

Dim iUserID as Integer

iUserID = Me.UserID

If Me.Password.Value = DLookup("Password", "Contacts", "[UserID] = " & iUserID) Then

I would also suggest doing the whole thing with variables:

Dim iUserID As Integer
Dim sPass As String
Dim sLook As String

iUserID = Me.UserID
sPass = Me.Password
sLook = DLookup("Password", "Contacts", "[UserID] = " & iUserID)

If sPass = sLook Then...

I can't verify your DLookUp() syntax.

This takes a little more writing but is more manageable. I find a lot of coders have problems pulling values in the middle of processes instead of taking values from the form as variables and then coding with the variable values. It is also easier to troubleshoot, change and adapt when you do it this way.

Did any of that help? What are the values in the variables when you debug?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
Run-time error 2001 kcolli20 Access VBA 1 October 3rd, 2006 07:00 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM

All times are GMT -4. The time now is 05:59 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.