Insert Multiple Rows in table

namu

Registered User.
Local time
Today, 08:40
Joined
Dec 30, 2014
Messages
26
Hello,

I will appreciate if someone can help me with this.

I want to insert multiple records in a table but i always get runtime error 3061: Too few parameters. Expected 1.

I tried to google and it seems this is a very common issue when inserting multiple line. But still i cannot find the right solution. I don't know what i am missing here.

tblProjOverallSched (structure)
ID = autonumber
ProjectID = Number
Activity = Text
Percentage = Number

Code:
Dim ProjID As Integer

ProjID = Me.ID

If Not IsNull(Me.ID) Then
    CurrentDb.Execute ("INSERT INTO tblProjOverallSched (ProjectID, Activity, Percentage) VALUES (ProjID, 'Negotiation', 5);")
    CurrentDb.Execute ("INSERT INTO tblProjOverallSched (ProjectID, Activity, Percentage) VALUES (ProjID, 'Mobilization', 2);")
End If
 
You need to build ProjID into the string;

Code:
CurrentDb.Execute ("INSERT INTO tblProjOverallSched (ProjectID, Activity, Percentage) VALUES ([COLOR="Red"]" & ProjID & "[/COLOR], 'Negotiation', 5);")
 
That works really well. Thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom