Data type mismatch in criteria expression.

I've done this a million times, but I keep getting the error: Data type mismatch in criteria expression from the following code.

valCancel = DateTime.Now() & "-" & TracktionUser
strCancel = "Update CWE_Debug Set Cancel=@Cancel Where UserCode = '" & valUser & "' And ExamID = '" & valExam & "'"
cmdCancel = New OleDbCommand( strCancel, conTracktion )                                                            
cmdCancel.Parameters.Add( "@ExamID", OleDBType.Char).Value = valCancel                   
cmdCancel.ExecuteNonQuery()

valCancel is defined as a string and the Cancel field in my Access DB is ShortText. I've tried to update other fields in the table and got the same error. So I thought my DB got corrupted and I run repair. Is there a line of code to ask what oledbtype its looking for? I'm completely stumped on this one. Anybody have any ideas?
mosemadlAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
Can you state what that code is suppose to be doing, ...you naming is throwing me off...
0
mosemadlAuthor Commented:
I just need to update a field labeled 'Cancel' to be a string like "5/12/2015-Moseman".
0
Jeffrey CoachmanMIS LiasonCommented:
Cstr([Cancel])

Note that "Cancel" is a bad name for a field, ..as it is a reserved word.
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Jeffrey CoachmanMIS LiasonCommented:
Note that you should be able to concatenate values to a ate field without Cstr()...
0
mosemadlAuthor Commented:
According to this https://support.microsoft.com/en-us/kb/286335 its not a reserved word, but I'll try changing it anyway.
0
Jeffrey CoachmanMIS LiasonCommented:
It is a reserved word in VBA...
ex:
    Private Sub Combo1_BeforeUpdate(Cancel As Integer)

...it is also a property of some objects:
cancel Property
0
mosemadlAuthor Commented:
Nope! I renamed the field to 'CancelStr' and I still get data type mismatch. No idea what type it thinks it is.
0
mosemadlAuthor Commented:
That was weird. I changed the criteria for finding the record to update and it worked, but either way it found the same record. Possible it had to do with one of the criteria being a primary key.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
The filed name was not part of the issue, ..I merely mentioned the name as a note...

Lets be clear, ...did you then still wrapped the field in the cst() function:
Cstr(CancelStr)
...and you still got the error?
0
Jeffrey CoachmanMIS LiasonCommented:
ok great
0
mosemadlAuthor Commented:
I figured it out.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.