SQL

Ai_no_Bakayarou
07-11-2001, 07:29 PM
I know that i should not be asking this here but i need help badly....

Please any SQL expert please reply..

i declare a variable cal SQL then i write my SQL statement for VBA but it always pop out SQL syntax error..

Can help mi see what is wrong wif it??

SQL = "UPDATE Chemical" & _
"SET Chemical.balance = "" " & newLeft & " "" " & _
"WHERE CAS = ' " & validCAS & " ' " & _
" AND grade = ' " & validGrade & " ' " & _
" AND brand = ' " & validBrand & " ' " & _
" AND cata = ' " & validCata & " ' " & _
" AND supName = ' " & validSup & " ' "

Feel Helpless everytime...

jerryfchui
07-11-2001, 08:25 PM
change the phrase
SQL = "UPDATE Chemical" & _

to
SQL = "UPDATE Chemical " & _

cheers

Ai_no_Bakayarou
07-11-2001, 08:45 PM
Tks for ur suggestion.....

newLeft As Double, validCAS As String, validGrade As String, validBrand As String, validCata As Long, validSup As String

SQL = "UPDATE Chemical " & _
"SET Chemical.balance = '" + newLeft + "'" & _
"WHERE CAS = '" & validCAS & "'" & _
" AND grade = '" & validGrade & "'" & _
" AND brand = '" & validBrand & "'" & _
" AND cata = '" + validCata + "'" & _
" AND supName = '" & validSup & "'"

Lastly i want to ask u one last thing, how come it shows type mismatch???

jerryfchui
07-11-2001, 08:57 PM
change your phrase
"SET Chemical.balance = '" + newLeft to
"SET Chemical.balance = '" + cstr$(newLeft)

and change your phrase
" AND cata = '" + validCata + "'" & _
to
" AND cata = '" + cstr$(validCata) + "'" & _

It should be . your 'last'

typemismatch means you can't add a long or double to a string. You can add number to numbers and string to string. Can't mix them.

Ai_no_Bakayarou
07-11-2001, 09:08 PM
Whoah man.....

Hey realli LAST LAST .....

Now show Data type mismatch in criteria expression....

if i never guess wrongly it is because i converted them to string but the database can't compare because they are other data type.... so how do i solve it???

Sorrie man... surely LAST...

Ai_no_Bakayarou
07-11-2001, 09:14 PM
Can i ask u something.... wat if i set all the variables to string first then later at the string sentence, i convert them to long n double during the execute part...... is it possible this way???

Tt way is not possible but i found another way....

SQL has a CONVERT function but i do not know how to use it.... Do u have any idea abt using it...
<P ID="edit"><FONT class="small"><EM>Edited by Ai_no_Bakayarou on Wed Jul 11 10:44 PM.</EM></FONT></P>

jerryfchui
07-11-2001, 09:50 PM
I am not available now and for me I have no quick answer what you ask. Perhaps you need to explain more. But hope someone else could help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum