A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Forms Save



 
 
Thread Tools Display Modes
  #1  
Old December 10th, 2005, 06:18 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old December 10th, 2005, 06:22 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old December 10th, 2005, 07:01 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 08:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.