MS Access error to Update record using Date in Expression

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top