Save changes

G

Guest

I am using Access 2000 and Windows XP.

I have a form that I need to generate a pop up box to say "Do you want to
save changes" with options "Yes" or "No" for users to click on. If they
choose "No" then changes are undone. This only needs to happen when closing
the form, moving to a new/another record or saving updating and not for every
single change.

I have this code at the moment which I have put in the Form properties:

Function changessave()
Select Case MsgBox( _
"Changes have been made - Do you want to save?" _
, vbYesNo _
, "Continue with Save?")
Case vbYes
DoCmd.save
Case vbNo
DoCmd.RunCommand acCmdUndo
End Select
End Function

The problem is I also have a sub form (addresses) which is refreshed when
the 'Establishment' field (on the main form) is changed or just reselected.
Unfortunately this refreshes the whole form as well and triggers the
changessave function, which is not what I want.

Here is the refresh code:

Function Refresh()
On Error GoTo Refresh_Err
DoCmd.RunCommand acCmdRefresh
Refresh_Exit:
Exit Function
Refresh_Err:
MsgBox "Error"
Resume Refresh_Exit
End Function

Any help with this is most appreciated.

Thank you.
 
G

Guest

Sorry, I should have mentioned I have put the 'changessave' function in the
'before update' option of the form properties and I have put the 'refresh'
function in the 'onchange' option of the 'Establishment' field.

Thank you.
 
G

Guest

I have sorted it out myself.

I used Private Sub coding instead of functions. I put the changessave
function (now a Private Sub) in the form properties ('before update'). I set
the 'enabled' option of the sub form properties to 'No'. And finally I
created another Private Sub code for the Establishment field to display a
message saying "The 'Street' field will be updated the next time you enter
this record" and put this function in the 'onchange' option of the
Establisment field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top