Help with updating a form

octatyan

Registered User.
Local time
Yesterday, 17:20
Joined
Jan 10, 2003
Messages
36
Hi, I have a form that shows records one by one.

The form shows all information in textboxes that are enabled and not locked.

A user can view a record and make changes by typing in the textboxes.

How do I make it so that anytime a change is made (adding/deleting info), the form requires the user to "save update" whenever the form is closed or moves to a new record? In other words, the user must be prompted to save the record if they dont hit a "save update" button. This is done to make sure the user REALLY does want to change some info on that record.

Also, how do I create a button to save updates? Is there a name for this type of button or do I have to code it?

Any help is greatly appreciated. Thanks!

-tony
 
Last edited:
The behavior you're describing sounds just like how Access handles records in forms. When a form is closed, any pending changes to a record are saved. If you move to another record, your edits on the current record are automatically saved.

Is this different from what you're experiencing?

You can easily create a button to save record updates. Yes, you will need to put some code "behind" it, but it's really easy:
DoCmd.RunCommand acCmdSaveRecord
 
You're correct in all your assumptions, but I want access to prompt the user to save any changes made prior to moving to a new record or closing the form.

I want the user to manually click a SAVE CHANGES button so that the user does not accidentally change some of the info.

If the SAVE CHANGES button is not pressed before moving on to another record, Access should prompt the user and say "you made some changes, you must SAVE CHANGES before continuing."

* so basically I don't want Access to AUTOMATICALLY save changes when moving to another record. How do I do this?

-tony
 
Gotcha. You can put some code into the BeforeUpdate event of your form and it will run before saving changes to existing records and before adding new records. Use some code like this:

If Me.Dirty Then
  MsgBox "you must SAVE CHANGES before continuing", vbCritical
  DoCmd.CancelEvent
End If


The Me.Dirty checks to see if there are unsaved changes in the current record. The DoCmd.Cancel event cancels saving the record updates.
 

Users who are viewing this thread

Back
Top Bottom