Hotwheels59
Registered User.
- Local time
- Today, 06:05
- Joined
- Oct 12, 2009
- Messages
- 13
Hi all,
I am trying to run code through a form to ensure fields are populated. If the fields are populated, the code needs to allow a series of queries to run. If not, the code should stop the user cold until the fields are populated. Here's the code thus far...
Private Sub Command8_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Nz(ctl.Value, vbNullString) = vbNullString Then
MsgBox "Missing required information including the job code and title." & vbCrLf & "Please fill in all missing information and try again.", vbCritical, "Can't Save"
End If
Case Else
End Select
Next ctl
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendAuthority"
DoCmd.OpenQuery "qryAppendBudget"
DoCmd.OpenQuery "qryAppendCertifications"
MsgBox "New Job Added", vbInformation, "New Job Added"
DoCmd.Close acForm, "frmAddNewJob"
DoCmd.Close acForm, "frmCheckJobCode"
DoCmd.SetWarnings True
End Sub
However, being new to this, the quieries run regardless of the fatal error. I suspect the issue is there needs to be code where the blank line is after "Next ctl." Any help provided is much appreciated.
I am trying to run code through a form to ensure fields are populated. If the fields are populated, the code needs to allow a series of queries to run. If not, the code should stop the user cold until the fields are populated. Here's the code thus far...
Private Sub Command8_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If Nz(ctl.Value, vbNullString) = vbNullString Then
MsgBox "Missing required information including the job code and title." & vbCrLf & "Please fill in all missing information and try again.", vbCritical, "Can't Save"
End If
Case Else
End Select
Next ctl
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendAuthority"
DoCmd.OpenQuery "qryAppendBudget"
DoCmd.OpenQuery "qryAppendCertifications"
MsgBox "New Job Added", vbInformation, "New Job Added"
DoCmd.Close acForm, "frmAddNewJob"
DoCmd.Close acForm, "frmCheckJobCode"
DoCmd.SetWarnings True
End Sub
However, being new to this, the quieries run regardless of the fatal error. I suspect the issue is there needs to be code where the blank line is after "Next ctl." Any help provided is much appreciated.