Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    2

    Unanswered: Dlookup Runtime Error 13

    Hi

    i keep getting a runtime error 13 when I am trying to create a lookup in order to open a table based on a user ID number. Here's the code...

    Code:
    Private Sub Image67_DblClick(Cancel As Integer)
    
    If DLookup("[strAccess]", "[tblEmployees]", "[lngEmpID]= 3") Then
    
    DoCmd.OpenTable "tblEmployees", acViewNormal
    
    End If
    
    End Sub
    Anyone have any ideas?

    Thanks

    Tom

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    run time error 13 is a type mismatch
    is lngEmpID a column in the DB?
    and is it as the naming convention suggest of type long, or at least numeric

    BTW
    personally I abhor the idea of using such a naming convention for columns, for variable inside your code by all means, but not columns inside the db....
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2012
    Posts
    2
    Hi

    it is a column in a table which holds usersname, i.d. and password. it is an autonumber that is generated when a new user is added, however i am using somebody elses bespoke log in system and unfortunately these are the names of the columns in their table. i found it quite annoying however i have not bothered changing it, i probably should.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So assuming the coluns are al OK, the tabel name is OK
    the next bit I'd want to look at is the 'If DLookup'
    you may be better off explciitly testing for whatever

    whether thats testing for NULL or a specific response or NOT NULL.
    reading your fragment of code I suspect you using dlookup to see if ta user has access and if so allow them to open a form

    so it may be better to try something like

    Code:
    dim UserAccess as string
    UserAccess =  DLookup("[strAccess]", "[tblEmployees]", "[lngEmpID]= 3")
    if not Isnull(USerAccess) and UserAccess ="blah" then
    or whatever the value of strAccess is supposed to be (or NOT what its not supposed to be) then open the form
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •