Code:
Dim db As DAO.Database
Dim rs As Recordset
Dim strSQL As String
If Me.QuestionID = "Q22a" And Me.txtActualAnswer = "0" Then 'If Mental Illness: None, then skip to Q23a
Me.Dirty = False
Set db = CurrentDb()
Set rs = db.OpenRecordset("qryQuestionSkipQ22a", dbOpenDynaset)
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
strSQL = "INSERT INTO tblStudyData ([ActualAnswer]) VALUES(" & 99 & ") WHERE " & Me.QuestionID & " =" & rs!QuestionID & ");"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
rs.MoveNext
Loop
Set db = Nothing
Set rs = Nothing
Else
End If
Me.Form.Requery
End Sub
If a value for a certain question is selected, Im trying to auto-populate the answers for the next several questions, almost like a skip-pattern
so in this case, if "0" is selected for Q22a, then "99" is filled in the ActualAnswer for Q22b thru Q22g. If the value for Q22a is changed, its not a big deal if the "99"s get deleted or not, thats why I omitted the delete SQL string.
My syntax must be off Craig, what do you think? By the way I placed this in the AfterUpdate of txtActualAnswers (the bound control)