Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 February 1st, 2006, 05:30 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 2000: dlookup() errors

I have a large Access database that I have been programming for the past few months. Recently I made a small addition to the program, and suddenly my custom Employee Login screen no longer works. I know for a fact that it is this form in particular because I made the database load another form on startup, and the users could open it fine.

The code for the login screen is this:

Code:
Private Sub cmdLogin_Click()
    If IsNull(cboLogin.Value) Or cboLogin.Value = "" Then
        MsgBox "Please select a login username.", vbExclamation + vbOKOnly, _
        "Lien On Me Title Services, Inc."
        cboLogin.SetFocus
        Exit Sub
    End If

    If IsNull(txtPassword.Value) Or txtPassword.Value = "" Then
        MsgBox "Please enter a password.", vbExclamation + vbOKOnly, _
        "Lien On Me Title Services, Inc."
        txtPassword.SetFocus
        Exit Sub
    End If

    If txtPassword.Value = DLookup("Password", "tblOfficeStaff", "[ID]=" & cboLogin.Value) Then
        strUsername = DLookup("Firstname", "tblOfficeStaff", "[ID]=" & cboLogin.Value) & " " & _
        DLookup("Lastname", "tblOfficeStaff", "[ID]=" & cboLogin.Value)
        DoCmd.OpenForm "frmMain"
        DoCmd.Close acForm, "frmLogin"
    Else
        MsgBox "Incorrect password!", vbCritical + vbOKOnly, _
        "Lien On Me Title Services, Inc."
        txtPassword.SetFocus
    End If
End Sub
I think dlookup() is the culprit here, because it's the only code that does any work, and this form is the only place in the entire program that uses dlookup(). It says that it creates an error log, however, I can't seem to locate where it's at.

Any help would be greatly appreciated.

 
Old February 2nd, 2006, 11:50 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Set a breakpoint at the start and F8 step through the function if you want to find exactly where the error is occuring.

 
Old February 7th, 2006, 08:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Well, if the password is a string, you need to change this everywhere:

Code:
"[ID] = " & cboLogin.Value
to

Code:
"[ID] = '" & cboLogin.Value & "'"
By the way, the .Value property can be omitted. Oh, and I LOVE this name! "Lien On Me Title Services, Inc." Too funny!


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 7th, 2006, 03:32 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by SerranoG
 Well, if the password is a string, you need to change this everywhere:

"[ID] = " & cboLogin.Value
to
"[ID] = '" & cboLogin.Value & "'"

By the way, the .Value property can be omitted. Oh, and I LOVE this name! "Lien On Me Title Services, Inc." Too funny!
Well, for no reason and explaination, the login form is working again. I disabled it for a few days, and went to go do what you said and it worked without me having to change a thing. Go figure.

However, I did put add singlequotes for good housekeeping, thanks for the tip.

And glad you like our company's name. ;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 Driver for JDBC Errors cash Java Databases 2 December 22nd, 2006 01:18 AM
SQL 2000 SERVER+ACCESS ADP DLOOKUP MHONG Access ASP 1 October 25th, 2005 08:36 AM
SQL SERVER 2000 AND ACCESS 2000 ckentebe SQL Server 2000 3 June 17th, 2004 08:50 PM
Outlook 2000 errors byron Pro VB.NET 2002/2003 3 December 1st, 2003 10:17 AM
Outlook 2000 errors byron VB.NET 2002/2003 Basics 0 August 28th, 2003 09:08 AM





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