Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop acces from updating the database

Status
Not open for further replies.

Hitower

Programmer
Mar 28, 2002
11
NL
Ok i am guessing that this will be a simple one for u all but i dont know so i am just gonna ask neway :p.
When u do a query in a database and u change something in the form and u leave the form it automaticly saves the changes u have made. How can i interrupt that by means of like a msgbox promping to cancel it ? I want VB to ask if i want to keep the changes or not but i need the code to stop acces from updating the db when i press cancel :)
btw yes i am a newbie in this so dont laugh ok :)

Regards Hitower
any help would be cool tnx [afro]


 
Add the following code to the Before Update event of the form:

If MsgBox("Confirm Update? ", vbYesNo) = vbNo Then
Cancel = True
DoCmd.CancelEvent
End If

To do this:

Go to design view on the form, view the properties, select "[Event Procedure]" from the pulldown list of the "Before Update" property, then click on the three dot button to the right. Then add the above code as the function body.

Hope this helps,
Rgds,
Steve
 
tnx for the help Steve but it doesnt work it cancels all events.
i am using an goto next record button and when i press that while the previous record changed it will prompt me the "Confirm update ?" part but when u press no it cancels the "goto Next" event aswell ?!

Like i said i am a newbie [afro]

All help is welcome
 
HiTower,

You have a couple of options here:

(a) As part of the Warning message, advise the user to click on the escape button twice; this will then cancel the pending updates, and allow him to navigate to the next button without interference.

(b) Remove the line of code which reads "DoCmd.CancelEvent". This will cancel the record update, but should still obey the navigation event.

Rgds,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top