UPDATE STATEMENT

S

stw8

DoCmd.RunSQL ("UPDATE Sears SET Details = (Price) & ' - ' & (Quanity)")

In Visual Basic I type in the above command and it tells me that i Have a
syntax error. How do I solve this problem
 
D

Dirk Goldgar

stw8 said:
DoCmd.RunSQL ("UPDATE Sears SET Details = (Price) & ' - ' &
(Quanity)")

In Visual Basic I type in the above command and it tells me that i
Have a syntax error. How do I solve this problem

When you say "In Visual Basic", are you talking about VBA code executing
within Access, or are you talking about a standalone VB program? If the
latter, there's no DoCmd object in standalone VB; it's part of the
Access application.

If you mean this is giving an error in Access VBA, I don't see what's
wrong with it, assuming "Price" and "Quanity" (note the misspelling) are
fields in Sears.
 
D

Dave M

Is the value "Quanity" or "QuanTity"? But why are you doing this anyway? If
these are fields in the same table, Price and Quan(t)ity already store all
the information you need, and you can concatenate them in an unbound control
whenever you need to display or report them.
 
J

John Vinson

DoCmd.RunSQL ("UPDATE Sears SET Details = (Price) & ' - ' & (Quanity)")

In Visual Basic I type in the above command and it tells me that i Have a
syntax error. How do I solve this problem

Context? Are there fields named Price and Quantity (Quanity??) in the
table named [Sears], or are these variables in your VBA procedure?
What would be typical values in Price and Quantity, and what do you
want stored in the field named Details?

A couple of concerns: if Sears is the Sears company, and if you have
other tables named (say) WalMart and Gap, you're on dangerous ground;
storing data in tablenames is NEVER a good idea. And if you're
intending to store two values (Price and Quantity) in a single field,
you're in even worse trouble; it's *never* a good idea to do so.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Top