am checking for completed fields within a form in the Before Update event. However within the Form Unload event I am also using open args code to close the form and open the previous form. The problem is that when my MsgBox comes up and I check the OK button, the previous form opens!
Can anyone please advise? Thanks in advance
BEFORE UPDATE CODE
FORM UNLOAD CODE
Can anyone please advise? Thanks in advance
BEFORE UPDATE CODE
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Place an asterisk (*) in the Tag Property of the text
'boxes you wish to validate.
'Then in the BeforeUpdate Event of the form, copy/paste the following:
Dim msg As String, Style As Integer, Title As String
Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "*" And Trim(ctl & "") = "" Then
msg = "Data Required for '" & ctl.Name & "' field!" & nl & _
"You can't save this record until this data is provided!" & nl & _
"Enter the data and try again . . . "
Style = vbCritical + vbOKOnly
Title = "Required Data..."
MsgBox msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub
Code:
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Forms(Me.OpenArgs).Visible = True
Forms!Project_Edit.cboCompanyID.Requery
End Sub
Comment