When I run the code below it does everything I need it to do, except close the form... Before I added the required fields, I had originally used DoCmd.Close on the btnCxSave button, but now it closes the form before the Validation Code finishes running.
Thoughts?
Expand|Select|Wrap|Line Numbers
- Private Sub Form_BeforeUpdate(Cancel As Integer)
- If ValidateRecord = False Then
- Cancel = True
- End If
- End Sub
- Private Function ValidateRecord() As Boolean
- ValidateRecord = False
- 'confirm name is entered
- If IsNull(CxName.Value) Then
- MsgBox CxName.ValidationText
- CxName.SetFocus
- Exit Function
- End If
- 'confirm either tel or email is entered - must have a minimum of one contact method minimum
- If IsNull(CxTel.Value) Then
- If IsNull(CxEmail.Value) Then
- MsgBox CxTel.ValidationText
- CxTel.SetFocus
- Exit Function
- End If
- End If
- ValidateRecord = True
- End Function
- Private Sub btnCxSave_Click()
- ValidateRecord
- 'Forms("frmMAIN").[sbfmCx1_Customers].[Form].Requery
- 'Forms("frmMAIN").[sbfmCx2_Contacts].[Form].Requery
- 'Forms("frmMAIN").[sbfmCx3_Notes].[Form].Requery
- End Sub