If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Applying changes to record
Is there any way in Access 2003 to apply any edits to a record or entry of a
new record only when a user clicks on a button? Like when you edit a document, changes aren't applied to the document file unless you click save or save as. |
#2
|
|||
|
|||
Applying changes to record
i usually get around this by turning off the Close X button in the
form properties, and the making my own button for Cancel/Close that uses the Undo Record change command. that way they are forced to either click save, or click cancel and are not able to simply close the form by clicking the X. |
#3
|
|||
|
|||
Applying changes to record
You could use the form's Current event to set the value of an unbound (hidden)
text box to a value such as 1. In the Click event of the button, set the text box value to 2. In the form's Before Update event, check the text box value before saving the record: Private Sub Form_Current() Me.txtCheck = 1 End Sub Private Sub cmdSave_Click() Me.txtCheck = 2 Me.Dirty = False ' This saves the record End Sub Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.txtCheck = 1 Then MsgBox "You didn't click the Save button. Changes won't be saved." Me.Undo End If Exit Sub I wonder why you would want to do it this way, unless there is a need for something to happen each time the record is changed (print a report, send an e-mail, or whatever). You may want to give the users a chance to go back and click the required button rather than simply notifying them that the changes will be discarded: Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.txtCheck = 1 Then If MsgBox ("Click the button to save the record", vbOkCancel) = vbOK Then Cancel = True Me.CommandButtonName.SetFocus Else Me.Undo End If End If Exit Sub Use whatever error message you like, and use vbYesNo (or something else) instead of vbOKCancel if it makes more sense. Colorado wrote: Is there any way in Access 2003 to apply any edits to a record or entry of a new record only when a user clicks on a button? Like when you edit a document, changes aren't applied to the document file unless you click save or save as. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201001/1 |
#4
|
|||
|
|||
Applying changes to record
What if they navigate to another record?
ghetto_banjo wrote: i usually get around this by turning off the Close X button in the form properties, and the making my own button for Cancel/Close that uses the Undo Record change command. that way they are forced to either click save, or click cancel and are not able to simply close the form by clicking the X. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201001/1 |
#5
|
|||
|
|||
Applying changes to record
Colorado -
You can put code in the 'BeforeUpdate' event. You can create a form variable to track whether the button has been clicked or not. This would normally be a hidden unbound variable. The value should be set to False whenever the form is opened or a record changed. You set it True only when the button is clicked. Then in the BeforeUpdate event, if this variable is false, you set 'Cancel' to true. Otherwise you set the new variable back to false and the Save will happen. That is one high-level approach. Check it out. -- Daryl S "Colorado" wrote: Is there any way in Access 2003 to apply any edits to a record or entry of a new record only when a user clicks on a button? Like when you edit a document, changes aren't applied to the document file unless you click save or save as. |
#6
|
|||
|
|||
Applying changes to record
i don't allow that either :-)
i found a function that disables the mouse wheel in access while the form is open. works well in this particular database as the user doesnt really need to cycle through multiple records. |
#7
|
|||
|
|||
Applying changes to record
"ghetto_banjo" wrote in message ... i don't allow that either :-) Not even allowing them to go to another line in a subform? Tom Lake |
Thread Tools | |
Display Modes | |
|
|