Error 3061: Too few parameters - INSERT statement

G

Guest

I am recieveing an error message too few parameters, on the following code
below using an INSERT statement.

Dim DrivePath As String
Dim dbs As Database
Dim strParkwayName As String
Dim strCustomerNo As String
strCustomerNo = Me.CustomerNo
DrivePath = "G:\Highway Travel Permit\Highway Permit Demo\"
Set dbs = OpenDatabase(DrivePath & "Copy of Highway Travel.mdb")

'Belt Parkway
If Me.BeltParkway = True Then
strParkwayName = "Belt Parkway"
dbs.Execute " INSERT INTO tblTempParkway " _
& "([CustomerNo],[ParkwayName]) VALUES " _
& "(strCustomerNo, strParkwayName);"
End If

What am I missing in this code?

Thank You.
 
G

Guest

Concatenate the values of the variables into the string expression rather
than referencing them, delimiting the values with quotes as the CustomerNo
and ParkwayName columns appear to be of text data type, judging by the fact
that you've declared both variables as String:

dbs.Execute "INSERT INTO tblTempParkway " _
& "(CustomerNo,ParkwayName) VALUES " _
& "(""" & strCustomerNo & """,""" & strParkwayName & """)"

Ken Sheridan
Stafford, England
 
G

Guest

Thank You very much.

The extra set of quotes take care of the problem.




Ken Sheridan said:
Concatenate the values of the variables into the string expression rather
than referencing them, delimiting the values with quotes as the CustomerNo
and ParkwayName columns appear to be of text data type, judging by the fact
that you've declared both variables as String:

dbs.Execute "INSERT INTO tblTempParkway " _
& "(CustomerNo,ParkwayName) VALUES " _
& "(""" & strCustomerNo & """,""" & strParkwayName & """)"

Ken Sheridan
Stafford, England

iholder said:
I am recieveing an error message too few parameters, on the following code
below using an INSERT statement.

Dim DrivePath As String
Dim dbs As Database
Dim strParkwayName As String
Dim strCustomerNo As String
strCustomerNo = Me.CustomerNo
DrivePath = "G:\Highway Travel Permit\Highway Permit Demo\"
Set dbs = OpenDatabase(DrivePath & "Copy of Highway Travel.mdb")

'Belt Parkway
If Me.BeltParkway = True Then
strParkwayName = "Belt Parkway"
dbs.Execute " INSERT INTO tblTempParkway " _
& "([CustomerNo],[ParkwayName]) VALUES " _
& "(strCustomerNo, strParkwayName);"
End If

What am I missing in this code?

Thank You.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top