Results 1 to 3 of 3
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    DLookup Type Mismatch Error

    I have an unbound form with an unbound textbox; the type mismatch error hits this code behind a button:
    If (DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
    "And Nz([SuppressDate])")) Then

    The Medicaid_ID is entered into the SrchMed_ID unbound textbox and when the button is clicked it should look at the REturned_Mail table to see if there is an existing record if so, take action otherwise do something else.

    This code did work when was only entering numerical numbers, but I have now entered charac/numerical combined numbers. Below is the complete code set for the button:


    Private Sub Command5_Click()


    Dim MedID As String
    Dim SuppressDate As Date

    ' Get Value from Medicaid_ID textbox on the Form:
    Me.btnsrch.SetFocus
    Me.SrchMed_ID.SetFocus
    MedID = Me.SrchMed_ID.Text


    Dim Msg, Style, Title, Response, MyString

    If IsNull(DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
    DoCmd.OpenForm "RA_Processing", , , , acFormAdd
    Me.SrchMed_ID = ""
    Else
    If (DLookup("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
    "And Nz([SuppressDate])")) Then

    MsgBox ("Do not log RA's for this Medicaid ID:" & (Chr(13)) & (Chr(13)) & " " & [SrchMed_ID] & (Chr(13)) & (Chr(13)) & "Recycle this providers RA's")
    Me.SrchMed_ID = ""

    Else

    DoCmd.OpenForm "RA_Processing", , , "Returned_Mail.Medicaid_ID = '" & SrchMed_ID & "'"
    Me.SrchMed_ID = ""


    End If
    End If


    End Sub


    Any help solving this mystery will be greatly appreciated.
    Thanks,

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What's the bit with SuppressDate supposed to accomplish?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    If SuppressDate is populated then staff is instructed just to recycle and not enter the information; Otherwise open the form for data entry.

    Thanks for the reply, but I figured out that if I changed the DLookup to DCount for that line of code it works.

    If (DCount("[Medicaid_ID]", "Returned_Mail", "Medicaid_ID = '" & SrchMed_ID & "'" & _
    "And Nz([SuppressDate])")) Then

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

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  3. VBA DLookup - Type Mismatch
    By hannuk in forum Access
    Replies: 2
    Last Post: 01-03-2012, 06:33 AM
  4. Newbie. DLookup gives type mismatch error.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 05:22 AM
  5. DLookup not recognizing valid record/type mismatch
    By walter189 in forum Programming
    Replies: 3
    Last Post: 07-21-2011, 07:03 AM

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