DoCmd.OpenQuery "qappResponses"
The query is executed after the user clicks a "Close" button on a form, frmSubjects (which is referenced in the query), which saves the form (Me.Dirty = False) and sets it to invisible (Me.Visible = False).
This works:
CODE
DoCmd.OpenQuery "qappResponses"
But its SQL equivalent (below) gives the parameter error. Although I thought the Where clause was the problem, when I removed it I still get the error, suggesting it's happening in the first two lines or so. SubjectID, SurveyID, and QstnID are all numeric.
CODE
strSQL = "INSERT INTO tblResponses ( SubjectID, SurveyID, QstnID, Rspns ) " & _
"SELECT DISTINCTROW [Forms]![frmSubjects]![SubjectID] AS SubjectID, tblSurveysQuestions.SurveyID, tblQuestions.QstnID, tblQuestions.RspnsDefault " & _
"FROM tblQuestions INNER JOIN tblSurveysQuestions ON tblQuestions.QstnID = tblSurveysQuestions.QstnID " & _
"WHERE tblSurveysQuestions.SurveyID=" & 15 & _
"AND tblQuestions.RspnsType<>" & 10
CurrentDb.Execute strSQL, dbFailOnError
"SELECT DISTINCTROW [Forms]![frmSubjects]![SubjectID] AS SubjectID, tblSurveysQuestions.SurveyID, tblQuestions.QstnID, tblQuestions.RspnsDefault " & _
"FROM tblQuestions INNER JOIN tblSurveysQuestions ON tblQuestions.QstnID = tblSurveysQuestions.QstnID " & _
"WHERE tblSurveysQuestions.SurveyID=" & 15 & _
"AND tblQuestions.RspnsType<>" & 10
CurrentDb.Execute strSQL, dbFailOnError
Any ideas?