Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    159

    Unanswered: DLookup headache

    This code looks like it should work but all I get is datatype mismatch errors
    Any help would be appreciated

    Code:
    Public Function getUnmatchedUnit(lngVisitNo As Long) As String
          If Not IsNull(DLookup("[Unit]", "[tblUnmatchedUnits]", _
            "[Visit_no]=" & lngVisitNo)) Then
            getUnmatchedUnit = (DLookup("[Unit]", "[tblUnmatchedUnits]", _
                "[Visit_no]=" & lngVisitNo))
            Else
            getUnmatchedUnit = "???"
            End If

  2. #2
    Join Date
    May 2004
    Posts
    159
    Got it. The problem was a data type mismatch in the table. But if I changed the type there then other things broke. Been stumped on this before but i had an insight today. I fixed it by downloading the key field data twice into a local table. one field is numeric and one field text. That way I can link to whichever data type I need it to be.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I don't like the sound of that solution, but if you're happy...
    George
    Home | Blog

  4. #4
    Join Date
    May 2004
    Posts
    159
    Quote Originally Posted by georgev
    I don't like the sound of that solution, but if you're happy...
    It is a kludge but is there a better way? With cdate you can force convert the datatype for dates but is there a way to force convert a datatype to be text or number?

Posting Permissions

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