473,406 Members | 2,849 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,406 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 8560
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.