Hi ALl
I am writing the following code that will check if any of the controls is left blank when the Checkbox is clicked . If the control value is null then display an error message and Exit sub. The following code works fine for Unbound control and the bound textboxes but there are bound comboboxes and it doesn't check if they are blank.
Any help will be much appreciated.
Thanks
I am writing the following code that will check if any of the controls is left blank when the Checkbox is clicked . If the control value is null then display an error message and Exit sub. The following code works fine for Unbound control and the bound textboxes but there are bound comboboxes and it doesn't check if they are blank.
Code:
Private Function CheckIfEmpty(controlname, controlvalue, controltext) As Boolean
CheckIfEmpty = False 'Default Value
'ControlName.SetFocus
If controlvalue = "" Or IsNull(controlvalue) Then
CheckIfEmpty = True
MsgBox "A valid value is required for " & controltext, vbCritical, controltext & " Required"
controlname.SetFocus
End If
End Function
Private Sub ChkConfirm_Click()
If CheckIfEmpty(cboAgent, cboAgent, "Agent Name") Then Exit Sub
If CheckIfEmpty(cboAuditor, cboAuditor, "Auditor Name") Then Exit Sub
If CheckIfEmpty(txtVerintID, txtVerintID, "Verint ID") Then Exit Sub
If CheckIfEmpty(cboCallType, cboCallType, "Call Type") Then Exit Sub
If CheckIfEmpty(cboDirection, cboDirection, "Call Direction") Then Exit Sub
If CheckIfEmpty(CboChannel, CboChannel, "Channel") Then Exit Sub
If CheckIfEmpty(txtCallDate, txtCallDate, "Date of Call") Then Exit Sub
If CheckIfEmpty(txtObs, txtObs, "Date of Observation") Then Exit Sub
If CheckIfEmpty(txtdtfedback, txtdtfedback, "Date Feedback") Then Exit Sub
End sub
Any help will be much appreciated.
Thanks