Hello all. I am trying to validate my form before I update the table. I am getting hung up on the combo boxes. Can someone with a sharper mind than myself please take a look at this and see what is wrong and how to fix it.
Thanks in advance.
Thanks,
PROXI
Code:
Private Sub cmdSubmit_Click()
Dim ctl As Control, xCtl
Dim Msg As String, Style As Integer, Title As String, DL As String
DL = vbNewLine & vbNewLine
Select Case ctl.ControlType
Case acComboBox, acTextBox
For Each ctl In Me.Controls
If ctl.Tag = "Required" And Trim(ctl & "") = "" Then
Set xCtl = ctl
Exit For
End If
Next
If IsEmpty(xCtl) Then 'All required OK.
'Your code for printing report
Else 'At least one required missing.
Msg = "Required Data for '" & xCtl.Name & "' is missing!" & DL & _
"Click 'Yes' to go back and enter the data . . ." & DL & _
"Click 'No' to abort, and cancel printing report & close database. . ."
Style = vbCritical + vbYesNo
Title = "Required Data Error! . . ."
If MsgBox(Msg, Style, Title) = vbYes Then
ctl.SetFocus
Else
'Your code for closing database
End If
End If
Exit_cmbSubmit_Click:
Exit Sub
Err_cmbSubmit_Click:
MsgBox Err.Description
Resume Exit_cmbSubmit_Click
End Select
End Sub
Thanks in advance.
Thanks,
PROXI