datatype mismatch in criterion expression error
Hi guys,
I keep getting a "Data type mismatch in criterion expression" error.
I cant figure out whats wrong, ive googled but still cant seem to find the problem.
Code:
Private Sub cmdSave_Click()
c.Execute ("Update Addresses set buyerbookdate='" & txtBuyerbookdate.Value & "',buyerbooktime='" & txtBuyerbooktime.Value & "',bbratios='" & txtBuyerRatioS.Text & "' where orderno='" & Combo1.Text & "';")
MsgBox "Records Added Successfully!", vbInformation, "Save"
Exit Sub
ErrHand:
MsgBox Err.Description, vbCritical, "Error"
End Sub
Any help would be greatly appreciated!
Brian
Re: datatype mismatch in criterion expression error
i suspect buyerbookdate field is a date/datetime type and on your update query you're setting a string type, also the same case with buyerbooktime , what are the types of these fields (buyerbookdate and buyerbookdate) in your database.
for date field use #02/01/2011# instead of '02/01/2011'
e.g.
"Update Addresses set buyerbookdate=#" & txtBuyerbookdate.Value & "#, ...
Re: datatype mismatch in criterion expression error
What is the field type for orderno? If it is not text remove the single qoutes around Combo1.Text. As for the date suggestion in #2 if you are using access db ignore that otherwise follow it.
Re: datatype mismatch in criterion expression error
thanks for your replies. the orderno field is a text field, i am using an access database so how do i proceed from here? :)
Re: datatype mismatch in criterion expression error
The I would have you post the exact SQL that is being generated here. Also the field names in the table and thier data types.
Do you know how to get the actuall SQL that is being generated and run?
Re: datatype mismatch in criterion expression error
is the field bbratios of type string? if not remove " ' " single quote arround the txtBuyerRatioS.Text
Re: datatype mismatch in criterion expression error
buyerbookdate and buyerbooktime(fields) are date/time fields in access.
no, i dont know how to get the actual sql... ? :confused:
Re: datatype mismatch in criterion expression error
Set a breakpoint. step though the code line by line. Once you get to the line after you generate the SQL statement you can right click on the var. Once you do that you should get a menu to display the value. Also you can set watchs on variables that will let you know when on changes and what it contains after the change.
Re: datatype mismatch in criterion expression error
gosh, i have a lot to learn, ive never use breakpoints and watches and stuff before, i just run the program and wait for errors (really terrible i know)
Re: datatype mismatch in criterion expression error
You really need to learn to use breakpoints it is the minimum you need to be able to debug a program
Re: datatype mismatch in criterion expression error
off to google i go! thanks.
Any pointers on the initial problem ?
Re: datatype mismatch in criterion expression error
You havae issues in the SQL Statement. Either a field in named wrong/spelled worng or the datatype is not passing what you expect.
Re: datatype mismatch in criterion expression error
thanks for you help , much appreciated.