Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert statement using variables

Status
Not open for further replies.

ikim2000

MIS
May 23, 2002
22
0
0
CA
I get an error when I execute the below INSERT statement. Cost and Price are money data types:

sqlText = "Insert Into tblProduct(ID,Cost,Price) values ('" & vProductID &"',vCost,vPrice)"

Is my syntax correct for vCost and vPrice?
---------------------------------------------------------
When I try the statement below it works:

sqlText = "Insert Into tblProduct(ID,Cost,Price) values ('" & vProductID &"',15,25)"

Thanks,
ike
 
Hi,

Try this.....

sqlText = "Insert Into tblProduct(ID,Cost,Price) values ('" & vProductID & "'," & vCost & "," & vPrice & ")"

Sunil
 
Thanks, it worked.
Any explanation as to why "& cost &" vs. vCost ?
 
Hi,

VCost and vPrice r variabels used to form the SQL, so they have to be concatenated with the SQL string so that a Proper SQL String is formed.

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top