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

    Data Type MisMatch

    Code:
    CurrentDb.Execute "Update tblUser SET tblUser.UserPassword = '" & Replace(Me.Text4.Value, "'", "''") & "' WHERE [ID] = '" & Me.UserLogin & "'"
    Hi Everyone

    i am trying to run the above code when i run the code i get the data type mismatch error,



    i want to update the password filed in the table with the value entered in the Text4 (contains letters,numbers,symbols)

    Hope you could help me out to overcome this error.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    that means you are using a string in a number field, so dont use quotes around numbers:

    WHERE [ID] = " & Me.UserLogin

  3. #3
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    If your ID field is a number you need to remove the string delimiters from it - try;

    Code:
    WHERE [ID] = " & Me.UserLogin
    If not build the string before and examine it ;

    Code:
    Dim sSql as String 
    
    sSql = "Update tblUser SET tblUser.UserPassword = '" & Replace(Me.Text4.Value, "'", "''") & "' WHERE [ID] = " & Me.UserLogin 
    
    Debug.Print sSql   ' This will make the result of you string appear in the immediate window. You can cut  and paste that into the query editor to highlight the error
    
    CurrentDB.Execute sSql
    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