G
Guest
Hi. I've created a form for membership in my organization. I want 2 fields
to be required: "Member since" date field and "State".
Someone from the Access group helped me (long ago) with "Member since", but
I'm getting 2 error messages when I enter a member (without "Member since"),
save and close the form. My msg box says "Please enter Member 'Since' Date
to contine, or Click Cancel to erase this form." When I clidk "OK" to the
msg, an Access message pops up: "You can't save this record at this time". I
can go back and enter the "Member Since" date. 1) How can I get Access to
not show me it's error msg and just rely on my own msg box? 2) How can I add
that "State" is required and to erase the form if it is not completed, just
like I have for the other required field? I've included the code I have:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim iAns As Integer
If Member = True And IsNull(Me!MemberDate) Then
iAns = MsgBox("Please enter a Member 'Since' Date to continue, or click
Cancel to erase this record", vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!MemberDate.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
End If
End Sub
to be required: "Member since" date field and "State".
Someone from the Access group helped me (long ago) with "Member since", but
I'm getting 2 error messages when I enter a member (without "Member since"),
save and close the form. My msg box says "Please enter Member 'Since' Date
to contine, or Click Cancel to erase this form." When I clidk "OK" to the
msg, an Access message pops up: "You can't save this record at this time". I
can go back and enter the "Member Since" date. 1) How can I get Access to
not show me it's error msg and just rely on my own msg box? 2) How can I add
that "State" is required and to erase the form if it is not completed, just
like I have for the other required field? I've included the code I have:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim iAns As Integer
If Member = True And IsNull(Me!MemberDate) Then
iAns = MsgBox("Please enter a Member 'Since' Date to continue, or click
Cancel to erase this record", vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!MemberDate.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
End If
End Sub