S
Stephanie
Hi. I'm trying to streamline my not-so-pretty code, and
actully make it work. I'm checking to make sure that
certain fields are completed before updating the record.
Here, I've shown 2 conditions I'm checking for (although
I have about 4 in reality). Before I added "Exit Sub" I
was getting prompted for both conditions (if appropriate)
without being able to fix the first condition. Then I
got an Access msg box: No current record.
After I added the Exit Sub(s), only the first condition
prompt occurs (yah!) but then I get an Access msg box:
DoMenuItem cancelled. My coding skills are very limited
and I can't figure out how to get one prompt as
appropriate. I appreciate any insight. Thanks, Stephanie
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim iAns As Integer
If (Me!Option1) = 0 And (Me!Option2) = 0 Then
iAns = MsgBox("Please select either 'ITA Member'
or 'R.E.A.D. Team' to continue, or click Cancel to erase
this record", vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!Option1.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
Exit Sub
End If
If IsNull(Me!MemberDateName) And (Not IsNull(Option1) Or
Not IsNull(Option2)) Then
iAns = MsgBox("Please enter an 'Associated Since' Date
to continue, or click Cancel to erase this record",
vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!MemberDateName.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
Exit Sub
End If
End Sub
actully make it work. I'm checking to make sure that
certain fields are completed before updating the record.
Here, I've shown 2 conditions I'm checking for (although
I have about 4 in reality). Before I added "Exit Sub" I
was getting prompted for both conditions (if appropriate)
without being able to fix the first condition. Then I
got an Access msg box: No current record.
After I added the Exit Sub(s), only the first condition
prompt occurs (yah!) but then I get an Access msg box:
DoMenuItem cancelled. My coding skills are very limited
and I can't figure out how to get one prompt as
appropriate. I appreciate any insight. Thanks, Stephanie
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim iAns As Integer
If (Me!Option1) = 0 And (Me!Option2) = 0 Then
iAns = MsgBox("Please select either 'ITA Member'
or 'R.E.A.D. Team' to continue, or click Cancel to erase
this record", vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!Option1.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
Exit Sub
End If
If IsNull(Me!MemberDateName) And (Not IsNull(Option1) Or
Not IsNull(Option2)) Then
iAns = MsgBox("Please enter an 'Associated Since' Date
to continue, or click Cancel to erase this record",
vbOKCancel)
If iAns = vbOK Then
Cancel = True
Me!MemberDateName.SetFocus
Else
Cancel = True
Me.Undo ' erase the entire form
End If
Exit Sub
End If
End Sub