Hiding a Save Command Button

magister011

Registered User.
Local time
Today, 13:15
Joined
Aug 18, 2009
Messages
17
I am trying to make a save command button only appear on my form if the data on the form has been changed. I also want to be able to force the user to have to use that command button before he/she continues. I have tried the "On Dirty" event with no luck. Would anyone be able to assist me?

Thanks
Magister011
 
You are aware of course that unless you take extra steps, Access will save any changes when you either close the form or move to another record, right?
 
Yes, I am aware of that. I am trying to get the user to make sure the user has to save the data before they leave the form. I tried a message box with a 'before update' event. Here is the code I used:

'code start
Dim intResponse As Integer
Dim strMsg As String
strMsg = "Data on the form has changed. Do you want to save changes?"
intResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Confirm Action")
Select Case intResponse
Case vbNo
DoCmd.RunCommand acCmdUndo

Case vbYes
DoCmd.RunCommand acCmdSaveRecord
End Select
'code end

I ended up with a 2115 error whenever I chose 'Yes' and the DeBugger would stop on the bold line. If you have any suggestions. I would sure appreciate it. I have been struggling with this for 3 days at work.

Magister011
 
The only reasong your code is in the Form's BeforeUpdate event is because you are about to save the current record. You don't have to do anything more to save. Your UnDo is fine for no, otherwise don't do anything and it will save.
 

Users who are viewing this thread

Back
Top Bottom