Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2006, 12:43 AM
Authorized User
 
Join Date: May 2006
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?

EB
__________________
EB
 
Old June 8th, 2006, 06:56 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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?

mmcdonal





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





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