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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL in VBA Problem. Semantics?

Status
Not open for further replies.

karassik

Technical User
Mar 27, 2002
51
US
Hello and thank you for looking at my problem.

I get an error stating that "number of query values and detinations are not the same.

Can anyone tell me what is wrong with the following code in Access 2000 written in VBA:

Dim stSQL As String

DoCmd.SetWarnings False
stSQL = "INSERT INTO [tblTempRmgAdd]([JobID],[Design],[ProTrodes])"
stSQL = stSQL + " values ('" & Me.JobID & " ," & Me.Design & " ," & Me.ProTrodes & "');"
DoCmd.RunSQL stSQL
DoCmd.SetWarnings True
 
I think you need to look at the values statement again...any text field needs to be surrounded with quotes

e.g. (presuming jobid is numerical and the other fields are text)

try this


stSQL = "INSERT INTO tblTempRmgAd](JobID,Design,ProTrodes)"
stSQL = stSQL + " values (" & Me.JobID & " ,'" & Me.Design & "' ,'" & Me.ProTrodes & "');"

 
Dear Karrasik,

Looks like you have a set of single quotes near the parens.().

Give it a shot.

Tx,

M6
 
Dear Karrasik,

Do any of your text fields actually contains either single or double quotation marks - ' or ".

A quick way of checking your sql is to display it via msgbox just before the DoCmd.RunSQL stSQL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top