Dialog box to save data changes?

padlock

Registered User.
Local time
Today, 18:13
Joined
Mar 11, 2005
Messages
10
Hi everyone,

I have a client I'm currently working for that has dumped Access on me. I'm not originally here for Access and am sort of learning as I go along (I'm here to setup, run, and maintain servers, etc.)

The problem is they have a large contact database in Access, and want the forms to pop up a dialog asking if data changes are okay before actually updating. I know that Access normally just does the change, but there is an issue with someone that doesn't understand computers at all making a mess of it (adding in one client 15 times, each with one different piece of information, erasing things in an attempt to search, etc, etc.)

I've been going all over the place trying to research the issue for hours and have had no luck finding a solution. Any help would be beyond appreciated. Thanks in advance for any help!

-Walter
 
Save

Try this in the Before Update Event of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim strMsg As String
strMsg = "Data has been changed."
strMsg = strMsg & " Save this record?"

If MsgBox(strMsg, vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
Else
End If

On Error GoTo Form_BeforeUpdate_Err


Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
End Sub
 
Thank you!

Thank you! That works perfectly for what we need. I've been going nuts all day, and I'm not a coder, and this is a lot of weight off of my back. Thank you again, have a great one.

-Walter
 
One last question

That worked perfectly for an entire form. If I want to work it into an individual text box, I receive the error:

Run-time error '2046':

The command or action 'Undo' isn't available now.


They want it per individual text box now instead of the entire form (which I think makes more sense, but it's not up to me.) I've explained it's not what I normally do, and that I don't really know VB (I know enough to read basic code and have an idea what it's doing.)

Here's the slightly modified code incase I did something wrong with that:

Private Sub Billing_Contact_BeforeUpdate(Cancel As Integer)

Dim strMsg As String
strMsg = "Data has been changed."
strMsg = strMsg & " Save this record?"

If MsgBox(strMsg, vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
Else
End If

On Error GoTo Form_BeforeUpdate_Err


Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
End Sub


Thanks again for the help so far. Some people are never happy, heh.

-Walter
 
You can undo a specific control. Check the Access help files for the keyword Undo for examples. The pain on your part will be to code it for each specific object [text boxes, combo boxes, etc.]. Sounds like your users are asking for too much.
 
Definetly too much

Yes, I agree they're looking for too much. Doing it to each field is going to be very time consuming, because one form alone has 30+ fields on it. I think having it ask for a safe after editing the whole form works best, too. Other users are going to complain if they have to hit yes everytime they change a field, too, especially if they're adding a new user. Or they'll just start smacking yes no matter what, because it's easier (and we end up back at step one with screwed up info.)

Thanks for all the help again, everyone.

-Walter
 
Found a solution

I found a solution by using me.undo for the undo. Here's the code that works:

Private Sub Billing_Contact_BeforeUpdate(Cancel As Integer)

Dim strMsg As String
strMsg = "Data has been changed."
strMsg = strMsg & " Save this record?"

If MsgBox(strMsg, vbYesNo, "") = vbNo Then
Me.Undo

Else
End If

On Error GoTo Form_BeforeUpdate_Err


Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
End Sub

Almost too simple, swear that made it harder. Thanks again for the help with everything. Now on to bigger and better problems (like getting to the pub.)

Thanks again!
-Walter
 

Users who are viewing this thread

Back
Top Bottom