RunSQL asking for parameter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am a newbee, so need a little help

I have made a SQL statement which I am trying to run by RunSQL SQL command.

although the NewCA and OldCA field has been defined it asks again to enter the parameter. I guess below syntax is wrong....could somebody please let me know where it is wrong?

SQL = "UPDATE test SET test.CANumber NewCA WHERE (((test.CANumber)= OldCA))"


Many thanks for your help.
 
Avir said:
I am a newbee, so need a little help

I have made a SQL statement which I am trying to run by RunSQL SQL command.

although the NewCA and OldCA field has been defined it asks again to enter
the parameter. I guess below syntax is wrong....could somebody please let me
know where it is wrong?
Try

SQL = "UPDATE test SET test.CANumber " & NewCA & " WHERE
(((test.CANumber)= " & OldCA & "))"

assuming NewCA and OldCA are numeric, and it is all on one line.
Marc
 
NewCA and OldCA are strings (Alphanumric no.'s Like CA-25325A, CA-25252B

Could you please write the SQL statement again.

many thanks!
 
SQL = "UPDATE test SET test.CANumber = " & Chr(34) & NewCA & Chr(34) & "
WHERE test.CANumber = " & Chr(34) & OldCA & Chr(34)
 
Dear Va

Thanks for your help. Unfortunately it is still not working. now the program is giving Comple Error: Syntax Erro

Is there any alternate way (maybe db.Execute statement), but I guess it will need a correct SQL statemen
 
What Van suggested should be typed in as a single line of code.

To ensure wordwrap doesn't cause a problem, try it as:

SQL = "UPDATE test SET test.CANumber = " & _
Chr(34) & NewCA & Chr(34) & _
" WHERE test.CANumber = " & _
Chr(34) & OldCA & Chr(34)

If you still have problems, I suspect it's not that line that's causing
them, but some other line in your program.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Avir said:
Dear Van

Thanks for your help. Unfortunately it is still not working. now the
program is giving Comple Error: Syntax Error
Is there any alternate way (maybe db.Execute statement), but I guess it
will need a correct SQL statement
 
A small modification worked like a breez

SQL = "UPDATE test SET test.CANumber = " & Chr(34) & NewCA & Chr(34) & " WHERE test.CANumber = " & Chr(34) & oldCA & Chr(34

Many thanks
 
The working SQL String is *exactly* what I suggested!

So what was the problem previously?

--
HTH
Van T. Dinh
MVP (Access)


Avir said:
A small modification worked like a breeze

SQL = "UPDATE test SET test.CANumber = " & Chr(34) & NewCA & Chr(34) & "
WHERE test.CANumber = " & Chr(34) & oldCA & Chr(34)
 
Back
Top