Results 1 to 4 of 4
  1. #1
    koolbugs is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Posts
    4

    Unhappy need guidance in DLookup

    I have a table consisting of Employee Name, Dept, Username, password.



    I created a login form that will Dlookup the value of my to my EmployeeTbl.

    the username is selected in combobox, then password is entered in unbound txtbox. after that, it will compare the password to my table.

    The query is composed of SELECT Employeetbl.username, Employeetbl.[Employee Name], Employeetbl.Department FROM Employeetbl;

    My main problem is that I cant get it work. everytime I click the logincmd button, it returns "The expression you entered as query produced this error"

    my suspect is the dlookup script, which is way turning my head really bad now.

    so I desperately need your knowledge to make this work.

    or I wonder how DLookup really work.


    Private Sub logincmd_Click()
    Dim strpassword As Variant
    '
    'check to see if password is entered
    '
    If IsNull(txtpassword) = True Then
    strMessage = "Please enter your password"
    Style = vbCrtitical
    strTitle = "No Password Entered"

    MsgBox strMessage, Style, strTitle
    Me.txtpassword.SetFocus
    Exit Sub
    End If
    '
    'Get the password stored in Employees Table
    '
    If Me.txtpassword.Value = DLookup("password", "Employeetbl", "[username]=" & Me.nameCmbo.Value) Then
    username = Me.nameCmbo.Value

    DoCmd.Close acForm, "LoginFrm", acSaveNo
    DoCmd.OpenForm "TimeForm"
    Else
    strMessage = "Incorrect Password Entered"
    strMessage = strMessage & vbCr & vbCr
    strMessage = strMessage & "Please Enter it Again"
    Style = vbCritical
    strTitle = "Incorrect Password"
    MsgBox strMessage, Style, strTitle
    txtpassword.SetFocus
    End If
    End Sub
    Last edited by koolbugs; 03-21-2010 at 12:01 PM. Reason: additional info

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use this link for guidence, especially for a "string" value: http://www.mvps.org/access/general/gen0018.htm

  3. #3
    koolbugs is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Posts
    4
    Thanks a lot guys, I already saw that link, guess I wasnt just following the code

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad we could help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dlookup??
    By Vikki in forum Access
    Replies: 4
    Last Post: 02-16-2010, 07:59 AM
  2. Subform Dlookup
    By jbedward in forum Forms
    Replies: 7
    Last Post: 01-13-2010, 08:06 AM
  3. Need guidance on database
    By yak600 in forum Access
    Replies: 0
    Last Post: 08-04-2009, 07:46 AM
  4. Dlookup
    By janjan_376 in forum Access
    Replies: 20
    Last Post: 07-07-2009, 07:40 AM
  5. Access Novice Taking On Large Project - Need Guidance
    By gtangjr in forum Database Design
    Replies: 1
    Last Post: 04-04-2008, 08:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums