required fields 1/2 the time??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My code for a form requires 7 certain variables to be filled in:

Private Sub Form_Unload(Cancel As Integer)
If Not (IsNull(Me.TR_CLOSEDATE)) Then
If IsNull(Me.TR_DECISION) Then
MsgBox "Please enter the decision"
DoCmd.CancelEvent
End If

If IsNull(Me.........

I also have a command button, enabled only for certain people.

Here is my question: Data is entered, then the record needs to be deleted,
but how can I not require the 7 veriables when I delete the record. Because
when I delete it, I cannot close out of the form with out entering the
required veriables which creates a record..??
 
Dan @BCBS said:
My code for a form requires 7 certain variables to be filled in:

Private Sub Form_Unload(Cancel As Integer)
If Not (IsNull(Me.TR_CLOSEDATE)) Then
If IsNull(Me.TR_DECISION) Then
MsgBox "Please enter the decision"
DoCmd.CancelEvent
End If

If IsNull(Me.........

I also have a command button, enabled only for certain people.

Here is my question: Data is entered, then the record needs to be deleted,
but how can I not require the 7 veriables when I delete the record. Because
when I delete it, I cannot close out of the form with out entering the
required veriables which creates a record..??


I think you should be using the form's BeforeUpdate event
instead of the Unload event to perform data validation
checks.

If this is for a new record, there is nothing in the table
to delete so all you have to do is Undo the record using
Me.Undo.

If this is for an existing record, then you should Undo any
edits to the record before deleting it from the table.
 
Back
Top