1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

MS Access error to Update record using Date in Expression

Discussion in 'Software Development' started by JanJau, Feb 7, 2013.

Thread Status:
Not open for further replies.
  1. JanJau

    JanJau Thread Starter

    Joined:
    Feb 7, 2013
    Messages:
    1
    I have MS Access table "myTable" with field BegDate, AssignedTo, etc..fields. Try to update the record but i got an error "Data Type Mismatch in Expresssion"

    Data in "txtStart_Date" is copied from form frmName1.StartDte
    - [Forms]![frmName1].[StartDte] = [Forms]![frmName2].[txtStart_Date]

    I try to update the table "myTable" with below code executing in Form frmName2

    strPID = Me.PID
    strAssignedTo = Me.AssignedTo
    strStartDate = Me.txtStart_Date

    SQLScript = "UPDATE MyTable SET MyTable.AssignedTo = '" & strAssignedTo & "'" & _
    "WHERE (((MyTable.PID)='" & strPID & "') AND ((MyTable.BegDate)= '" & strStartDate & "'));"
    I got an error "Date Type mismatch in expression".

    I used the code below with "#":
    SQLScript = "UPDATE MyTable SET MyTable.AssignedTo = '" & strAssignedTo & "'" & _
    "WHERE (((MyTable.PID)='" & strPID & "') AND ((MyTable.BegDate)= #" & strStartDate & "#));"
    I don't get any error but table was not updated.

    If i'm going to eleminate the the code: AND ((MyTable.BegDate)= #" & strStartDate & "#));
    It works but all record with the same PID was updated. I need only a specified record to update.

    I appreciate if anyone can help me.
    Thanks a lot.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1088576

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice