Check insert code

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi

Appreciate if you will help me with this code. Now it returns an error,
Runtime error '3601' too few parameters, expected 2.

Thanks in advance.
Richard

Private Sub CmdInsert_Click()

Dim DB As DAO.database
Dim EnrolID As Integer
Dim PartID As Integer

EnrolID = Me.EnrolmentID
PartID = Me.cmbPart

Set DB = CurrentDb

DB.Execute ("INSERT INTO [Enrolment/Participant] " & _
"VALUES (EnrolID,PartID)")
Set DB = Nothing
End Sub

--
 
The SQL statement is not valid.

Use the query design window to create a dummy query statement, using any
values you choose. Swtich to SQL View. Copy the statement you see there.
Then concatenate the actual values from the form into the string, e.g.:
"INSERT ..." & Me.EnrolID & ", " & Me.PartID ");"
 
Thanks for your reply, Allen

Should I use the select query and change accordingly? Tried it once and
didn't work, will try to work around it abit.

Thanks again
Richard

--


Allen Browne said:
The SQL statement is not valid.

Use the query design window to create a dummy query statement, using any
values you choose. Swtich to SQL View. Copy the statement you see there.
Then concatenate the actual values from the form into the string, e.g.:
"INSERT ..." & Me.EnrolID & ", " & Me.PartID ");"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.


Richard said:
Hi

Appreciate if you will help me with this code. Now it returns an error,
Runtime error '3601' too few parameters, expected 2.

Thanks in advance.
Richard

Private Sub CmdInsert_Click()

Dim DB As DAO.database
Dim EnrolID As Integer
Dim PartID As Integer

EnrolID = Me.EnrolmentID
PartID = Me.cmbPart

Set DB = CurrentDb

DB.Execute ("INSERT INTO [Enrolment/Participant] " & _
"VALUES (EnrolID,PartID)")
Set DB = Nothing
End Sub
 
Back
Top