PatrickStel
New member
- Local time
- Today, 02:14
- Joined
- Dec 18, 2015
- Messages
- 1
Hi Gents,
I've run in to a issue with VBA Query.
I'm trying to insert a query into the table with VBA but what ever I try to do it gets stuck on something.
I have this code in VBA for the inserting part.
When I'm running this query and put it in a MsgBox to see the out come I'm getting this
But every time It's going through the Execute part I'm getting this error.
Hope you guys can help me.
With kind regards,
Patrick
I've run in to a issue with VBA Query.
I'm trying to insert a query into the table with VBA but what ever I try to do it gets stuck on something.
I have this code in VBA for the inserting part.
Code:
Dim dbs As Database
' Set the Current Database
Set dbs = CurrentDb
'Testing purpose
Me.cbPenalty1 = 0
Me.cbOwnGoal1 = 0
' Create a new record in the tblMatchPlayer table.
' Query saved the player who scored with values in a new row, linked with MatchID & PlayerID.
MsgBox " INSERT INTO tblMatchPlayer " _
& "(MatchID, PlayerID, SubstituteID, PositionID, Surname, ScoreTime, RedCards, YellowCards, Substitude, Penalty, OwnGoal, Assist) VALUES " _
& "(" & Me.MatchID & ", '', '', '', " & Me.cmScoreName1 & ", " & Me.tbScoreTime1 & ", '', '', '', " & Me.cbPenalty1 & ", " & Me.cbOwnGoal1 & ", " & Me.cmAssist1 & ");", vbOKOnly, "Query Show"
dbs.Execute " INSERT INTO tblMatchPlayer " _
& "(MatchID, PlayerID, SubstituteID, PositionID, Surname, ScoreTime, RedCards, YellowCards, Substitude, Penalty, OwnGoal, Assist) VALUES " _
& "(" & Me.MatchID & ", '', '', '', " & Me.cmScoreName1 & ", " & Me.tbScoreTime1 & ", '', '', '', " & Me.cbPenalty1 & ", " & Me.cbOwnGoal1 & ", " & Me.cmAssist1 & ");"
dbs.Close
So it looks okay, the empty fields are there cause I have to extends the parts writing to the table, the fields are all ready in the field.INSERT INTO tblMatchPlayer (MatchID, PlayerID, SubstitudeID, PositionID, Surname, ScoreTime, RedCards, YellowCards, Substitude, Penalty, OwnGoals, Assist) VALUES (29, '', '', '', Grozema, 34, '', '', '' 0, 0, Bruins)
But every time It's going through the Execute part I'm getting this error.
I've searched on the internet and found out other people were having this as well but I didn't find a solution.Run-time error '3061':
Too few parameters. Expected 2.
Hope you guys can help me.
With kind regards,
Patrick