I have the following in the OnClick Event of a "Save" button:
Private Sub cmd69_Click()
On Error GoTo Err_cmd69_Click
Dim currctl As Integer, numctls As Integer
Dim ctl As Control
numctls = Forms!frmAddProject.Count 'counts the number of controls
For currctl = 0 To numctls - 1
Set ctl = Me(currctl)
If Me!cboAddStatus = "C" Then
MsgBox "A Formal Presentation Completion date is required for Completed Projects", vbOKOnly
Me!Form_Pres_Comp.BackColor = 65535
Me!Form_Pres_Comp.SetFocus
End If
Exit Sub
If ctl.Tag = "validate" Then
If IsNull(ctl) Then
MsgBox "You have not filled in information that is required for this project. Please fill in the fields highlighted in YELLOW.", 48, "Field Empty"
ctl.BackColor = 65535
ctl.SetFocus
Exit Sub
End If
End If
Next currctl
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close
Exit_cmd69_Click:
Exit Sub
I am trying to first, require a date be entered in a field if a combobox value is "Complete" and second, require additional dropdowns be selected before saving the record.
My code has me stuck in a loop on the first IF statement. What am I missing?
Private Sub cmd69_Click()
On Error GoTo Err_cmd69_Click
Dim currctl As Integer, numctls As Integer
Dim ctl As Control
numctls = Forms!frmAddProject.Count 'counts the number of controls
For currctl = 0 To numctls - 1
Set ctl = Me(currctl)
If Me!cboAddStatus = "C" Then
MsgBox "A Formal Presentation Completion date is required for Completed Projects", vbOKOnly
Me!Form_Pres_Comp.BackColor = 65535
Me!Form_Pres_Comp.SetFocus
End If
Exit Sub
If ctl.Tag = "validate" Then
If IsNull(ctl) Then
MsgBox "You have not filled in information that is required for this project. Please fill in the fields highlighted in YELLOW.", 48, "Field Empty"
ctl.BackColor = 65535
ctl.SetFocus
Exit Sub
End If
End If
Next currctl
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close
Exit_cmd69_Click:
Exit Sub
I am trying to first, require a date be entered in a field if a combobox value is "Complete" and second, require additional dropdowns be selected before saving the record.
My code has me stuck in a loop on the first IF statement. What am I missing?