Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too few parameters. Expected 1 2

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi There,
I'm getting a "Too few parameters. Expected 1." message with this code, can anyone see why.

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim strSQL As String


strSQL = "INSERT INTO tblTeams ( TGameNo, TTeam, TFor, TAgainst )" & _
"SELECT tblGameScore.GameNo, tblfixtures.FTeam1, tblGameScore.For, tblGameScore.Against " & _
"FROM tblGameScore INNER JOIN tblfixtures ON tblGameScore.GameNo = tblfixtures.GameNo " & _
"WHERE (((tblGameScore.GameNo)=[forms]![frmDataEntry]![GameNo])) "

CurrentDb.Execute strSQL, dbFailOnError


Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub

It works without the where clause.
 
Try:

"WHERE (((tblGameScore.GameNo)="""" & [forms]![frmDataEntry]![GameNo] & """" & ")) "

Ed Metcalfe.


Please do not feed the trolls.....
 
Hi Ed,
Sorry I had to change the code slightly but i tried this and it does not like the ")) saying "Expected end of Statement"

strSQL = "INSERT INTO tblTeams ( TTeam, TFor, TAgainst )" & _
"SELECT tblfixtures.FTeam1, tblGameScore.For, tblGameScore.Against " & _
"FROM tblGameScore INNER JOIN tblfixtures ON tblGameScore.GameNo = tblfixtures.GameNo " & _
"WHERE (((tblfixtures.GameNo)="""" &[forms]![frmDataEntry]![GameNo]))& """" & ")) "
 
Too many close brackets I think. I've never been sure why MS Access puts them all in anyway.

Give this a go:

strSQL = "INSERT INTO tblTeams ( TTeam, TFor, TAgainst )" & _
"SELECT tblfixtures.FTeam1, tblGameScore.For, tblGameScore.Against " & _
"FROM tblGameScore INNER JOIN tblfixtures ON tblGameScore.GameNo = tblfixtures.GameNo " & _
"WHERE tblfixtures.GameNo="""" &[forms]![frmDataEntry]![GameNo]& """" & ";"

Please do not feed the trolls.....
 
And if tblGameScore.GameNo is defined as numeric:
"WHERE tblGameScore.GameNo=" & Forms!frmDataEntry!GameNo

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks guys for the help, I got a syntax error with ed's code ";" but PHV your's worked great.

Tom
 
PHV - Well spotted. :)

Ed.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top