473,231 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Is There A Way to Pop Up a MessageBox Warning When User Changes Data?

Dear Access 2003 Users,

Is there a way to pop up a MessageBox warning when a user changes data
on a form? Basically, I have one field that I really want people to
think about before changing, so when they get to that field (which is
the first tab stop on a continuous form), if there is data in it and
they change it, I would love a MessageBox popping up saying "Are you
sure that you want to change XXXX to YYYY?". If they hit Yes, the
changes are applied, No they revert back to the other data. Any
ideas? Thanks!

Kevin
Jan 30 '06 #1
6 8535
I have something similar, but it is set on the entire for. The code
runs on the before update.

Here is the code.

Private Sub Form_BeforeUpdate(Cancel As Integer)

'confirm with user that this record is to be modified

Dim updRecord As Byte

On Error GoTo Form_BeforeUpdate_Error

updRecord = MsgBox("Confirm record change", vbOKCancel, "Record
Modification")

If updRecord = vbCancel Then
Cancel = True

End If

'Dim priordate As Variant
'Dim prioruser As Variant
Me!DateModified = Now()
Me!UserModified = CurrentUser()

On Error GoTo 0
Exit Sub

Form_BeforeUpdate_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure Form_BeforeUpdate of VBA Document Form_Customers"
End Sub

Hope this helps.

"No Spam" <no****@earthlink.net> wrote in message
news:oh********************************@4ax.com:
Dear Access 2003 Users,

Is there a way to pop up a MessageBox warning when a user changes data
on a form? Basically, I have one field that I really want people to
think about before changing, so when they get to that field (which is
the first tab stop on a continuous form), if there is data in it and
they change it, I would love a MessageBox popping up saying "Are you
sure that you want to change XXXX to YYYY?". If they hit Yes, the
changes are applied, No they revert back to the other data. Any
ideas? Thanks!

Kevin


Jan 30 '06 #2
Put an event procedure on the on change event.

Then put the following code in the event procedure:

Field - is the name of the field on the form. Change this to the field
name that is on your form.

Private Sub Field_Change()

If MsgBox("do you want to change this ?", vbYesNo) = vbNo Then
Me!Field.Undo
End If

End Sub

Jan 30 '06 #3
On Mon, 30 Jan 2006 22:30:04 GMT, No Spam wrote:
Dear Access 2003 Users,

Is there a way to pop up a MessageBox warning when a user changes data
on a form? Basically, I have one field that I really want people to
think about before changing, so when they get to that field (which is
the first tab stop on a continuous form), if there is data in it and
they change it, I would love a MessageBox popping up saying "Are you
sure that you want to change XXXX to YYYY?". If they hit Yes, the
changes are applied, No they revert back to the other data. Any
ideas? Thanks!

Kevin


Code that control's AfterUpdate event:

If Me!ControlName.OldValue <> Me!ControlName Then
If MsgBox("Are You sure", vbYesNo) = vbNo Then
Me!ControlName = Me!ControlName.OldValue
End If
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 31 '06 #4
Probably not where you want to put the code -- on change fires on each
keystroke. BeforeUpdate is a good place... if they respond that they do not
want to change, it has a Cancel argument to cancel the update.

Larry Linson
Microsoft Access MVP

"cjb_kjb" <cj*****@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Put an event procedure on the on change event.

Then put the following code in the event procedure:

Field - is the name of the field on the form. Change this to the field
name that is on your form.

Private Sub Field_Change()

If MsgBox("do you want to change this ?", vbYesNo) = vbNo Then
Me!Field.Undo
End If

End Sub

Jan 31 '06 #5
Thanks to everyone who helped with this! One added request - if
someone highlights the data in the field, deletes it, and moves on,
this code does not capture that. Any ideas!

Thanks a million!

On Mon, 30 Jan 2006 17:48:45 -0800, fredg <fg******@example.invalid>
wrote:
On Mon, 30 Jan 2006 22:30:04 GMT, No Spam wrote:
Dear Access 2003 Users,

Is there a way to pop up a MessageBox warning when a user changes data
on a form? Basically, I have one field that I really want people to
think about before changing, so when they get to that field (which is
the first tab stop on a continuous form), if there is data in it and
they change it, I would love a MessageBox popping up saying "Are you
sure that you want to change XXXX to YYYY?". If they hit Yes, the
changes are applied, No they revert back to the other data. Any
ideas? Thanks!

Kevin


Code that control's AfterUpdate event:

If Me!ControlName.OldValue <> Me!ControlName Then
If MsgBox("Are You sure", vbYesNo) = vbNo Then
Me!ControlName = Me!ControlName.OldValue
End If
End If


Jan 31 '06 #6
It looks like Nz did the trick!

On Tue, 31 Jan 2006 18:11:07 GMT, No Spam <no****@earthlink.net>
wrote:
Thanks to everyone who helped with this! One added request - if
someone highlights the data in the field, deletes it, and moves on,
this code does not capture that. Any ideas!

Thanks a million!

On Mon, 30 Jan 2006 17:48:45 -0800, fredg <fg******@example.invalid>
wrote:
On Mon, 30 Jan 2006 22:30:04 GMT, No Spam wrote:
Dear Access 2003 Users,

Is there a way to pop up a MessageBox warning when a user changes data
on a form? Basically, I have one field that I really want people to
think about before changing, so when they get to that field (which is
the first tab stop on a continuous form), if there is data in it and
they change it, I would love a MessageBox popping up saying "Are you
sure that you want to change XXXX to YYYY?". If they hit Yes, the
changes are applied, No they revert back to the other data. Any
ideas? Thanks!

Kevin


Code that control's AfterUpdate event:

If Me!ControlName.OldValue <> Me!ControlName Then
If MsgBox("Are You sure", vbYesNo) = vbNo Then
Me!ControlName = Me!ControlName.OldValue
End If
End If


Jan 31 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: s-galit | last post by:
hi, i have a module that created a form, and the messageBox is shown in the closing event , but when the im choosing the "cancel" button in the messageBox the messageBox and also the form is...
7
by: Bill | last post by:
For some reason, I have an errormessage popup that "blinks", but pops up BEHIND the applications, which is confusing to users. Is there any way to force it to the top?
4
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
13
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I...
4
by: mac | last post by:
Hi! I've created a simple ASPX form that displays a record from a SQL Server table. I have a "Delete" button on the form. When the user clicks it, I want to prompt the user with a message ("Are...
2
by: randy1200 | last post by:
I have the following line of C# code: MessageBox.Show(filesThatDoNotExist, "Files Not Found", MessageBoxButtons.OK); This line generates the following warning when I select "Run Code Analysis"...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
5
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my...
5
by: Cubicle Intern | last post by:
Hi, I have a form with multiple fields that confirmed before the form is submitted (ex. email field needs to be completed before the form can be submitted). Once the required fields are...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.