|
-
Feb 1st, 2011, 02:41 PM
#1
Thread Starter
Lively Member
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
-
Feb 1st, 2011, 02:48 PM
#2
Lively Member
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 & "#, ...
-
Feb 1st, 2011, 02:51 PM
#3
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 1st, 2011, 03:09 PM
#4
Thread Starter
Lively Member
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?
-
Feb 1st, 2011, 03:16 PM
#5
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?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 1st, 2011, 03:20 PM
#6
Lively Member
Re: datatype mismatch in criterion expression error
is the field bbratios of type string? if not remove " ' " single quote arround the txtBuyerRatioS.Text
-
Feb 1st, 2011, 03:22 PM
#7
Thread Starter
Lively Member
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... ?
-
Feb 1st, 2011, 03:25 PM
#8
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 1st, 2011, 03:41 PM
#9
Thread Starter
Lively Member
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)
-
Feb 1st, 2011, 03:42 PM
#10
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 1st, 2011, 03:50 PM
#11
Thread Starter
Lively Member
Re: datatype mismatch in criterion expression error
off to google i go! thanks.
Any pointers on the initial problem ?
-
Feb 1st, 2011, 03:59 PM
#12
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 1st, 2011, 04:04 PM
#13
Thread Starter
Lively Member
Re: datatype mismatch in criterion expression error
thanks for you help , much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|