Conflicting Code

  • Thread starter Thread starter alex
  • Start date Start date
A

alex

Conflicting Code

Hello,
Using Access ’03…

In a form module, I have some code in the form’s before update event
that checks the value of two controls to make sure they’re not null or
= “”. This way, users cannot leave the record without the two
controls possessing a value.

I also have a delete button that deletes a record with the standard
wizard issued code:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

My question/issue is this:
A user is on a record and one (or both) of the controls does not
contain a value. If the user wants to delete the record, the form’s
before update event fires and my message box pops up informing the
user that one/both of the control(s) is null.

In this case, the user doesn’t care; he/she just wants to delete the
record.

How can I code around this?

Thanks,
alex
 
There's several ways to handle this depending on what logic you want to
implement when someone modifies a record and then hits delete.
One way is to test whether the record has been modified before deleting it
so at the top of your Delete Button code:

If Me.Dirty Then
DoCmd.RunCommand acCmdUndo
End If

-Jon


Conflicting Code

Hello,
Using Access ’03…

In a form module, I have some code in the form’s before update event
that checks the value of two controls to make sure they’re not null or
= “”. This way, users cannot leave the record without the two
controls possessing a value.

I also have a delete button that deletes a record with the standard
wizard issued code:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

My question/issue is this:
A user is on a record and one (or both) of the controls does not
contain a value. If the user wants to delete the record, the form’s
before update event fires and my message box pops up informing the
user that one/both of the control(s) is null.

In this case, the user doesn’t care; he/she just wants to delete the
record.

How can I code around this?

Thanks,
alex
 
Put something in the boxes before the delete code or set a variable in the
delete code that you can check for in the before update event

Box1 = "Z"
Box2 = "Z"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
 
There's several ways to handle this depending on what logic you want to
implement when someone modifies a record and then hits delete.
One way is to test whether the record has been modified before deleting it
so at the top of your Delete Button code:

    If Me.Dirty Then
        DoCmd.RunCommand acCmdUndo
    End If

-Jon


Conflicting Code

Hello,
Using Access 03

In a form module, I have some code in the form s before update event
that checks the value of two controls to make sure they re not null or
= .  This way, users cannot leave the record without the two
controls possessing a value.

I also have a delete button that deletes a record with the standard
wizard issued code:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

My question/issue is this:
A user is on a record and one (or both) of the controls does not
contain a value.  If the user wants to delete the record, the form s
before update event fires and my message box pops up informing the
user that one/both of the control(s) is null.

In this case, the user doesn t care; he/she just wants to delete the
record.

How can I code around this?

Thanks,
alex

Jon,
That seemed to work just fine (I should have thought of that?). I
appreciate the help!
alex
 
"alex" <[email protected]> kirjoitti
viestissä:d5c9c87e-3c3b-46eb-b1a7-f4e95d6fa023@o30g2000yqb.googlegroups.com...
Conflicting Code

Hello,
Using Access ’03…

In a form module, I have some code in the form’s before update event
that checks the value of two controls to make sure they’re not null or
= “”. This way, users cannot leave the record without the two
controls possessing a value.

I also have a delete button that deletes a record with the standard
wizard issued code:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

My question/issue is this:
A user is on a record and one (or both) of the controls does not
contain a value. If the user wants to delete the record, the form’s
before update event fires and my message box pops up informing the
user that one/both of the control(s) is null.

In this case, the user doesn’t care; he/she just wants to delete the
record.

How can I code around this?

Thanks,
alex
 
Back
Top