click to save

  • Thread starter Thread starter LG
  • Start date Start date
L

LG

If you have a form and they make a correction how would you go about creating
a button they have to click that feeds back to the table saying yes in the
correction field? Clicking that button will save the changes but if you
don't no changes will be made.
 
Hi LG
if I understand your request, you can put a save button and a cancel button
on the form.
The Save button uses code like this-->
If Me.Dirty = TrueThen
Me.Dirty = False
End If


The Cancel button-->
If Me.Dirty = True Then
Me.Undo
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
LG said:
If you have a form and they make a correction how would you go about
creating
a button they have to click that feeds back to the table saying yes in the
correction field? Clicking that button will save the changes but if you
don't no changes will be made.
 
LG said:
If you have a form and they make a correction how would you go about
creating
a button they have to click that feeds back to the table saying yes in the
correction field? Clicking that button will save the changes but if you
don't no changes will be made.
 
What I am wanting to do is the following:
I have added a corrrection field to the table. When they go into the edit
form it takes them to the table I want them to have to click on a button that
will tell the correction field Yes. Then changes that were made to that
record would be saved. If they don't click that yes button it won't save
changes. I am trying to be able to run accurate reports later on, on how
many corrections were made and who made the most errors for reviews.
 
For a single form add the following:

Private Sub cmdSave_Click()
Me.Dirty = False
End Sub

Private Sub Form_Close()
Me.Undo
End If

hth

pieter
 
What I am wanting to do is the following:
I have added a corrrection field to the table. When they go into the edit
form it takes them to the table I want them to have to click on a button that
will tell the correction field Yes. Then changes that were made to that
record would be saved. If they don't click that yes button it won't save
changes. I am trying to be able to run accurate reports later on, on how
many corrections were made and who made the most errors for reviews.

Are you *OPENING THE TABLE* as a table datasheet, from the form? If so you
don't have any control over what they do, and you're making a mistake!

If on the other hand the form is bound to the table, so they're using the form
as a tool to edit the data, then you can put code in the form's BeforeUpdate
event to check the state of the button. Put a concealed textbox on the form,
chkOKToClose let's say. You need three lines of code:

1. In the Form's Current event put

Me!chkOKToClose = False

2. In the command button's Click event set it to True.

3. In the form's BeforeUpdate event check it:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!chkOKToClose = False Then
MsgBox "Discarding your edits since you didn't click the button", vbOKOnly
Cancel = True
End If
End Sub
 
Back
Top