Conflicting Code


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
 
Ad

Advertisements

J

Jon Lewis

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
 
R

RonaldoOneNil

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
 
A

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

Jon,
That seemed to work just fine (I should have thought of that?). I
appreciate the help!
alex
 
Ad

Advertisements

R

Risse

"alex" <[email protected]> kirjoitti
viestissä:[email protected]m...
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top