Results 1 to 4 of 4
  1. #1
    the_rock is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    4

    DLookup problem

    Hi,



    I am attempting to authenticate a password using Dlookup. This doesn’t not have to very secure hence why I am doing it like this.
    I want to have an input box appear, the user to type the password and for the script to see if they are permitted to run one query.

    This is what I have so far.

    Code:
    Private Sub tech_approval_Click()
    On Error GoTo Err_tech_approval_Click
    
    
        Dim stDocName As String
        Dim Di As Integer
        Dim Pass As Integer
        
        'launch user inout box
        strPass = InputBox("Please enter your password", "Password")
            
        'query table tech_password and hold the value of tech_id in the variable Result
        Result = DLookup("tech_id", "tech_password", "password ='" & strPass & "'")
        
        'query variable result and if it is greater then 1 ie there is a password that matched allow
        'to run query tech_approavl
        'if tech_id is less than 1 ie no password matched then trutn message box
        
        If (Result < 1) Then
        stDocName = MsgBox("Incorrect password", vbExclamation + vbOKOnly, "Error")
        MyVar3 = MsgBox(Result)
        Else
        MyVar4 = MsgBox(Result)
        DoCmd.OpenQuery "tech_approval", acViewNormal, acEdit
        End If
        
    
    Exit_tech_approval_Click:
        Exit Sub
    
    Err_tech_approval_Click:
        MsgBox Err.Description
        Resume Exit_tech_approval_Click
        
        
    End Sub
    I am currently only getting the error, "you cancelled the previous operation"
    Any help would be much appreciated

  2. #2
    the_rock is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    4
    Ok So I have the dlookup working now.
    typical, been working on it for days then decide to post and get it working pretty much straight away!!

    Although now is the password is correct then the query works. However if an incorrect password is entered then it return” invalid use of null" instead of the mgs box.

    Any thoughts?

  3. #3
    the_rock is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    4
    I think it is because the dlookup is returning a null value

  4. #4
    the_rock is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    4
    problem sorted. used nz(dlookup) to stop trtunring null value

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

Similar Threads

  1. Dlookup problem
    By metronometro in forum Queries
    Replies: 1
    Last Post: 01-07-2012, 12:17 PM
  2. Using Dlookup problem
    By Lupson2011 in forum Access
    Replies: 5
    Last Post: 12-07-2011, 10:33 AM
  3. Newbie Dlookup problem
    By opopanax666 in forum Programming
    Replies: 7
    Last Post: 08-13-2010, 05:47 AM
  4. dlookup function problem
    By bdaniel in forum Programming
    Replies: 3
    Last Post: 04-26-2010, 05:55 AM
  5. Dlookup problem
    By CalifDan in forum Reports
    Replies: 4
    Last Post: 12-09-2009, 06:09 AM

Tags for this Thread

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