Results 1 to 5 of 5
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Data Type MisMatch


    HI

    Code:
    
    Lid1 = Me.Text78 'ID (Not Enabled & Locked)
    Lid2 = Me.Text62 'Passport_Number
    Lid3 = Me.Text15 'Student_ID (Not Enabled & Locked)
    
    CurrentDb.Execute "Update Alumni_List SET [Surname] = '" & Me.Text5 & "' WHERE [ID]= '" & Lid1 & "' AND [Passport/Number]= '" & Lid2 & "' AND [Student_ID]= '" & Lid3 & "'"
    When i execute the above code, i get Datatype mismatch error. Please advice me what is wrong here?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I presume ID and Student_ID are number fields. Do not use apostrophe delimiters with number type.

    Why would you need all 3 criteria? Can a student have multiple passport numbers? Why would you save Surname to Alumni_List and not just Student_ID? Why even have a separate table for alumni?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hey

    Student ID contains letters as well.
    Code:
    CurrentDb.Execute "Update Alumni_List SET [Surname] = '" & Me.Text5 & "' WHERE [ID]= Lid1 AND [Passport/NIC_Number]= '" & Lid2 & "' AND [Student_ID]= '" & Lid3 & "'"
    i changed the code as above, but i still get the error "Too Few Parameters, Expected 1"

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You are not concatenating Lid1 variable.

    CurrentDb.Execute "Update Alumni_List SET [Surname] = '" & Me.Text5 & "' WHERE [ID]= " & Lid1 & " AND [Passport/Number]= '" & Lid2 & "' AND [Student_ID]= '" & Lid3 & "'"
    Last edited by June7; 10-31-2019 at 02:26 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As advised here - https://www.accessforums.net/showthread.php?t=78631
    You will save yourself time if you get into the habit of building the SQL expression into string and debug.print it - your error would have been more obvious.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Data type mismatch
    By DMT Dave in forum Access
    Replies: 7
    Last Post: 06-14-2019, 10:00 AM
  2. keep getting data type mismatch
    By tagteam in forum Access
    Replies: 3
    Last Post: 04-05-2018, 02:26 PM
  3. data type mismatch
    By ottoc in forum Queries
    Replies: 1
    Last Post: 12-02-2014, 09:42 AM
  4. Data Type Mismatch in SQL
    By Phred in forum Queries
    Replies: 2
    Last Post: 01-04-2012, 03:40 PM
  5. Data Type Mismatch
    By timmy in forum Programming
    Replies: 9
    Last Post: 04-12-2011, 03:48 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