Multiple Variables For Insert INTO SQL Statement

lhooker

Registered User.
Local time
Today, 06:31
Joined
Dec 30, 2005
Messages
423
Can someone take a look at the below SQL 'INSERT INTO' statement ? I'm trying to insert multiple variable values into an 'INSERT INTO' statement. I'm getting the below error message. The code is listed below. I started out with two (2) variables, but will have thirteen to insert into a table. Also, in the code below is the VBA statement to retrieve the variable data. I'm getting the data, but cannot insert the data into the table. Thanks ! ! !


**********************************************************

Private Sub Test2_Click()

Dim strSQL As String
Dim strSalesman As String
Dim strContentArea As String
DoCmd.SetWarnings False

strSalesman = Forms![Salesman Evaluation - Form B]![Salesman].Column(0)
strContentArea = Forms![Salesman Evaluation - Form B]![Content Area].Column(0)


strSQL = "INSERT INTO [Sales Evaluations] (Salesman, Content_Areas) VALUES ('" & strSalesman & "',strContentArea)"

Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError

End Sub

Error
Microsoft Visual Basic popup
Run-time error '3061'

Too few parameters. Expected 1.

*********************************************************
 
l,

strSQL = "INSERT INTO [Sales Evaluations] (Salesman, Content_Areas) VALUES ('" & strSalesman & "','" & strContentArea & "')"

hth,
Wayne
 
Wayne,

That worked . . . Thanks ! ! ! The date columns are not posting the correct date (i.e '9/13/2013' is displayed as '12/30/1899'). What is causing this ?
 
l,

The delimiter for the date columns is the # symbol.

Were one of those fields a date??

If so, change the single-quote to the #.

Wayne
 
Wayne,

Yes, there are 'Text', 'Date/Time', 'Yes/No', and 'Memo' data type fields.
 
Wayne,

I re-entered each field one-by-one and all errors were eliminated. So, this was a user error. Thanks for your previous answer ! ! ! It was the correct solution. Thanks again ! ! !:o
 

Users who are viewing this thread

Back
Top Bottom