You are here:

Visual Basic/VB in MS Access

Advertisement


Question
Hi there,

would you be able to give me the code i could use in MS Access so when someone edits the data and tries to close the form, then an error message is displayed asking the user whther would they like to save or not.

Yes = form saved
no = form not saved
cancel = takes back in the form.

Could you give me the VB code for this?

Thanks

Answer
This is actually a very difficult thing in Access because they've tried to do it all for you.  So when you close, any uncommitted changes are automatically saved.  The only way to cut that off at the pass is to put code in the BeforeUpdate event for the form and ask to confirm everytime.

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Robert Nunemaker

Expertise

String manipulation, Database access and usage, Class creation, and encapsulation are my strong suits. Active X Controls and DLL`s also. Although I don`t deal with Crystal - frankly because I don`t like it; I prefer to do things manually.

Experience

Employment history: Programmed with the Air Force for 15 years, and have continued in the private sector for the past 1 year. Used VB (all versions) for the past 8 years.

Organizations: MCP and MCSD certified.

Education: Computer Science Bachelor degree.

Awards: MCP and MCSD certified.

©2012 About.com, a part of The New York Times Company. All rights reserved.