Results 1 to 4 of 4
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181

    DLookup Data Mismatch Error

    I have a form that I would like to update with an ID after saving. I would like to look up the ID after saving with the phone number provided.
    My form text box Phone1 has the data with an input mask, like (555) 555-5555, saving as 5555555555.
    The data table field Phone1 also has the same input mask, and saves the data without the mask.
    The data table field Phone 1 is Short Text, and the form field Phone1 is Plain Text.

    I am using this code to lookup the FamilyID field in the Family table with the Phone1 field.

    Code:
    Me.FamilyID = DLookup("[FamilyID]", "Family", "[Phone1] = " & Me.Phone1)
    I keep getting a "Data Type Mismatch" error.

    I can save to the field using an INSERT INTO query, but I can't seem to lookup after saving.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    If phones are strings,you must include delimiters:

    ,"[phone]= '" & me.phone1 & "'")

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    Quote Originally Posted by ranman256 View Post
    If phones are strings,you must include delimiters:

    ,"[phone]= '" & me.phone1 & "'")
    Delimiters fixed it. Thanks!

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

Similar Threads

  1. Type mismatch error using Dlookup
    By dgmdvm in forum Forms
    Replies: 7
    Last Post: 02-22-2017, 07:52 PM
  2. DLookup Type Mismatch Error
    By DCV0204 in forum Forms
    Replies: 2
    Last Post: 02-11-2014, 01:54 PM
  3. DLookUp DataType Mismatch Error
    By theosgood in forum Programming
    Replies: 2
    Last Post: 10-29-2013, 10:04 AM
  4. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  5. Newbie. DLookup gives type mismatch error.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 05:22 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