Using MS Access/Alert in a Form

Advertisement


Question
good day,
i have a form with 3 fields CODE, ITEM, QUANTITY, and this fields are filled up with many data. I need to change the 3rd field (QUANTITY) every month leaving the other two's (CODE and ITEM) unchanged.
I need to set up an alert in these two fields (CODE and ITEM) whether by mistake i have changed it.
I tried with the following codes:

Private Sub Form_BeforeUpdate(Cancel As Integer)
   If MsgBox("Changes have been made to this record." _
       & vbCrLf & vbCrLf & "Do you want to save these changes?" _
       , vbYesNo, "Changes Made...") = vbYes Then
         DoCmd.Save
       Else
         DoCmd.RunCommand acCmdUndo
   End If

but they doesn't work in my form. Maybe i missed out some passages.

Answer
Instead of the UNDO command, just say:

Cancel=1

That should cancel your changes.

Be sure to visit my web site and watch my FREE 2-hour-long Microsoft Access Video Tutorial

Cordially,
Richard Rost
599CD Computer Training  

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Richard Rost

Expertise

I am happy to answer any kinds of questions about Microsoft Access - from basic table design to advanced VBA programming. Also, please feel free to check the Access Tips & Tricks section of my web site, and free Access 101 tutorial.

Experience

I am the president of AccessLearningZone.com and 599CD.com. I specialize in Microsoft Access Tutorials. I have been teaching Access in the classroom since 1994, and online since 2002.

Education/Credentials
I am a self-taught Access expert. I have been building databases for clients since the early 90s. You can see a sample of my Access Tutorials on my web site at 599CD.com

©2016 About.com. All rights reserved.