Hi,
I have the following code which worked fine before I entered the highlighted if statements to validate.
What i want is before any procedure takes place the first process is to check if all the combo boxes are populated/have value. Therefore, if if any is not a message box is prompted to ask the user to select a choice for that question.
Incase any of the combo boxes is not filled then the sub terminates..
any help please.. thank you
Code:
Private Sub Submit_Click()
If (cmbcri1.Value) = 0 Then
MsgBox "Please answer Question1"
End If
If (cmbcri2.Value) = 0 Then
MsgBox "Please answer Question2"
End If
If (cmbcri3.Value) = 0 Then
MsgBox "Please answer Question3"
End If
If (cmbcri4.Value) = 0 Then
MsgBox "Please answer Question4"
End If
Exit Sub
DoCmd.RunSQL "DELETE TblTemp.* FROM TblTemp"
DoCmd.GoToRecord , , acNewRec
DoCmd.RunSQL "INSERT INTO TblTemp(Que1W,Que2W, Que3W,Que4W) VALUES ('" & cmbcri1 & "','" & cmbcri2 & "','" & cmbcri3 & "','" & cmbcri4 & "');", dbSeeChanges + dbFailOnError
DoCmd.OpenQuery "QryAppendTblDetails"
'MsgBox ("Record saved")
Dim rs As DAO.Recordset, strMessage
Set rs = CurrentDb.OpenRecordset("QryWSMScores")
If Not rs.EOF Then
strMessage = Chr(13) & Chr(10)
rs.MoveFirst
Do Until rs.EOF
strMessage = strMessage & Space(20) & rs.Fields(0) & Chr(13) & Chr(10)
rs.MoveNext
Loop
MsgBox " Business Options Based on WSM Score " & strMessage
End If
cmbcri1.Value = 0
cmbcri2.Value = 0
cmbcri3.Value = 0
cmbcri4.Value = 0
End Sub