Need a "confirm change" dialogue when editing MS Access form field

Posted on 2007-10-10
Last Modified: 2013-11-28
Hi All,
Basically my boss wants an added level of proetection from careless people changing part numbers and quantities in his electronics parts database. So this has to apply to only two fields in the form.

We need a dialogue box to pop up when the user changes the contents of a form field, preferably when they move to the next field or record. There are two special needs here that prevent me from using the "After Update" event in the Properties panel and then building a macro that pops up a Msgbox warning:

1)  It can't happen with new records - it can only occur when the user goes back and makes a change to an existing record with the "Qty" and "Mfg Part Number" fields already filled out
2)  They want the pop-up warning box to say "Are you sure you want to make changes". (Y)es and (N)o keyboard stroke must work in conjunction with the warning box. (Y)es would allow the user to continue to the next field or record.....(N)o would just stay in the field

My utmost appreciation to anybody who can make this work, and explain generally how to apply it to the field.

Question by:hiviper
    1 Comment
    LVL 65

    Accepted Solution

    In the Qty and 'Mfg Part Number' BeforeUpdate event...

    Private Sub ThatFieldName_BeforeUpdate(Cancel as Integer)

    'If it's a new record, bail here.
    If Me.NewRecord then exit sub

    'Make sure user entered a value, else bail.
    If Nz(Me.ThatFieldName, "") = "" then exit sub

    Select Case msgbox("Are you sure you want to make changes", vbYesNo, "A title goes here")
      Case vbYes
         'Make the change code here
      Case vbNo
         'User cancelled the change.  Do nothing
         Cancel = True
    End Select

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now