Results 1 to 3 of 3

Thread: Dlookup Syntax

  1. #1
    Join Date
    Sep 2009
    Posts
    23

    Unanswered: Dlookup Syntax

    Please help!!! I can't figure out what's wrong with this code:

    Dscnt = DLookup("[DscntPct]", "[TCustDscnt]", _
    "[CustName] = '" & Forms![FInvMasterEdit]![CustName] & "'" _
    And "[DeptID] = '" & Me.cboDeptID & "'")

    When i run it shows: Run-time error: '13' Type Mismatch

    Thnx.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Welcome to the forums

    For one, your AND statement is outside the string declaration, Access wouldn't know how to handle this:

    Dscnt = DLookup("[DscntPct]", "[TCustDscnt]", _
    "[CustName] = '" & Forms![FInvMasterEdit]![CustName] & "'" _
    And "[DeptID] = '" & Me.cboDeptID & "'")
    Try this instead:

    Code:
    Dscnt = DLookup("[DscntPct]", "[TCustDscnt]", _
                "[CustName] = '" & Forms![FInvMasterEdit]![CustName] & _
                "' AND [DeptID] = '" & Me.cboDeptID & "'")
    Of that doesn't work, make sure Form FInvMasterEdit is open, and that all the controls match.

    If that still doesn't work, make sure the field types are text (or possibly memo, but that would probably not be the case, I hope).
    Me.Geek = True

  3. #3
    Join Date
    Sep 2009
    Posts
    23
    WOW! What a quick reply and it works.Thanx Nick!

    Try this instead:
    Code:

    Dscnt = DLookup("[DscntPct]", "[TCustDscnt]", _
    "[CustName] = '" & Forms![FInvMasterEdit]![CustName] & _
    "' AND [DeptID] = '" & Me.cboDeptID & "'")

Posting Permissions

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