We help IT Professionals succeed at work.

How to have save button in continuous form

LISA GEORGE
LISA GEORGE used Ask the Experts™
on
Hi all, is there anyway we can have Save button in continuous form. user wants to save only when he clicks on save button or else changes he made must not change.
I know how we can do this for single form but is it possible anyway for continuous form as he desparately wants that? is there any work around on how to save changes in continuous form if users wants to or else discard the changes.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
Yes,

I usually put the save button in the continuous forms footer, rather than put a button in the detail section that will simply repeat itself

Then, in the forms code declaration section I create a private variable (bCanSave)
Private bCanSave as boolean

Open in new window

In the Form_Current event, I set this value to False
Private Sub Form_Current
    bCanSave = False
End Sub

Open in new window

Alternatively, you could put this in the Form_Dirty event, in which case it would only fire when you have dirtied a record instead of every time you click on a new record.
Then, in the Form_BeforeUpdate event, I use:
Private Sub Form_BeforeUpdate(Cancel as Integer)
    Cancel = iif(bCanSave, false, true)
    if Cancel then 
        msgbox "click the 'Save' button to save the record"
    end if
End Sub

Open in new window

Finally, in the click event of cmd_Save, I use:
Private Sub cmd_Save_Click
    bCanSave = true
    me.dirty = false
End Sub

Open in new window

LISA GEORGEMICROSOFT DEVELOPER

Author

Commented:
thanks Dale for your valuable time.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
glad to help.