syntax problem - data type mismatch

krc777

Registered User.
Local time
Today, 11:48
Joined
Nov 29, 2005
Messages
70
I have this code in a module in Access:

CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = '" & fssn & "'"

The MISSN is a double data type in the table.
The fssn is a varient/double in the code. I get a data type mismatch on this line. Can anyone tell me what I'm doing wrong?
Thanks.
 
Is firstDate a date format or text? I think you need to remove the " " from " & fssn & "'
 
When I took out the WHERE statement the line ran fine so it's in the WHERE. I've tried removing quotes still get the error. Thanks for your suggestions though.
k
 
krc777 said:
When I took out the WHERE statement the line ran fine so it's in the WHERE. I've tried removing quotes still get the error. Thanks for your suggestions though.
k

If the fssn field is a number field, don't you need to remove the single quotes and use ## instead.

I'm no genius, but that is just an idea.
 
You dont need anything on the number field afaik.

See if
Code:
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = " & fssn
works
 
workmad3 said:
You dont need anything on the number field afaik.

See if
Code:
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = " & fssn
works

Thank you,

so the ## are used for? Date fields? I'm still not an expert on that. I only know that text requires " or ' depending.
 
I tried removing the quotes and replacing with #. Error about the #'s.
If anyone could tell me or give me the URL of a site with all the various possibilities like formating a string, ' " & string & " ' or number ?? or date, that would be so helpful.
k
 
krc777 said:
I tried removing the quotes and replacing with #. Error about the #'s.
If anyone could tell me or give me the URL of a site with all the various possibilities like formating a string, ' " & string & " ' or number ?? or date, that would be so helpful.

k

sorry krc...wasn't trying to confuse you.

Try this link. It has some SQL tutorials in it.
 
I tried:
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = 'fssn' "
no luck. Still data mismatch error.
 
krc777 said:
I tried:
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = 'fssn' "
no luck. Still data mismatch error.


If fssn is a number field, remove the single quotes from around it.
 
If I remove all the quotes like MISSN = fssn then I get the too few parameters error. When the Quotes are in and I check it in the window it has the correct number. I just can't get find the right syntax to get the line to go.
Thanks.
 
I have no idea why but this worked.
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = Cstr(' & fssn & ')"

The data type for this field is number but this worked.
k
 
krc777 said:
I have no idea why but this worked.
CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = Cstr(' & fssn & ')"

The data type for this field is number but this worked.
k


The reason it worked, is because that Cstr. convereted your number datatype to a string datatype, and the quotes around that field made it work.
 
When you say you removed all the quotes, did you get rid of the double quotes as well?

What you really want, like I said, is

CurrentDb.Execute "UPDATE Matchonyyyymm Set FirstDate = 'Y' WHERE MISSN = " & fssn
 
oh, and standard SQL just has ' for strings (or " if you are typing directly into an sql console) and the lack of them for numbers. # is an access (and possibly SQL server) identifier for date types.
 

Users who are viewing this thread

Back
Top Bottom