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
|
|||
|
|||
Forms Save
Have added Form Save Button through add button option in form and then
selected save form option. Now suppose i have filled half of the form and if i cancel form by pressing X and close it, without pressing save button, the form closes but half of data is present. Is there way I cant close form unless i press save button or I can save partial data unless i press save button |
#2
|
|||
|
|||
Forms Save
Please read my last line as "I Can't Save partial Data Unless i Press save
button" "Sandy" wrote: Have added Form Save Button through add button option in form and then selected save form option. Now suppose i have filled half of the form and if i cancel form by pressing X and close it, without pressing save button, the form closes but half of data is present. Is there way I cant close form unless i press save button or I can save partial data unless i press save button |
#3
|
|||
|
|||
Forms Save
There are myriads of ways that the record in the form can get saved, such as
applying a filter, changing the sort order, closing the form, moving to another record, pressing Shift+Enter, through the Records menu, closing Access itself, and so on. The only way to catch them all is to use the BeforeUpdate event of the form. 1. Declare a form-level variable. In the General Declarations section of your form's module (top, with the Option statements): Dim mbAllowSave As Boolean 2. In the Click event of your button, set the variable to True before the save, and reset it afterwards: Private Sub cmdSave_Click() mbAllowSave = True RunCommand acCmdSaveRecord mbAllowSave = False End Sub 3. Cancel Form_BeforeUpdate if the variable is not True, because the button was not clicked: Private Sub Form_BeforeUpdate(Cancel As Integer) If mbAllowSave Then mbAllowSave = False 'reset it. Else Cancel = True MsgBox "Use the Save button." End If End Sub When you close the form while it is dirty, Access still asks whether to continue (and lose the edits) or stay editing. While it is possible to trap that in the Error event of the form, there's probably not a better alternative. The user does need to know the edit will be lost, and if you make it too hard for them to get out they'll corrupt your database by justing turn off without exiting properly. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Sandy" wrote in message ... Please read my last line as "I Can't Save partial Data Unless i Press save button" "Sandy" wrote: Have added Form Save Button through add button option in form and then selected save form option. Now suppose i have filled half of the form and if i cancel form by pressing X and close it, without pressing save button, the form closes but half of data is present. Is there way I cant close form unless i press save button or I can save partial data unless i press save button |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Default save on exit for ppt should be 'do save' not 'don't save' | publicityshy | Powerpoint | 3 | August 11th, 2006 06:48 PM |
Prompt for save when save just performed | DL | General Discussions | 0 | September 4th, 2005 07:23 AM |
How do you force a Save As in a Word based form? | Diane R. | General Discussion | 2 | January 12th, 2005 05:59 PM |
Forms Will Not Save | accessquestion | General Discussion | 1 | January 12th, 2005 08:28 AM |
Save and Save As tab disappeared from File Menu | Karen | General Discussion | 2 | January 10th, 2005 12:30 AM |