How to display a msgbox if on data change if field value wasn't nu

Is this possible to accomplish?

A field (MyField) contains some text.  When a user changes or deletes that 
text, I display a message box asking the user if he really wanted to change 
the text in MyField.  The way my code is set up, the message box displays 
after every data change.  (I'm not very good at writing code.)

Dim ChgAnswer As Integer, MsgTitle As String, MsgDialog As Integer
    Const MB_YESNO = 4
    Const MB_ICONEXCLAMATION = 48
    Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
    
    If Not IsNull(Me.MyField) Then
    Beep
    MsgTitle = "Data Change"
    MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
    ChgAnswer = MsgBox("Do you really want to change the data in this 
field?", MsgDialog, MsgTitle)
    
        If ChgAnswer = IDNO Then
        Me.Undo
        End If
    End If


I want the message box to appear ONLY if MyField already contained a value.  
If the field was null, I don't want the message box to display.

What's the best event to use for this purpose?  (I'm currently using 
BeforeUpdate.)  Can anyone help clean up my code?

Thanks very much.
0
Utf
6/23/2007 12:25:00 AM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
1309 Views

Similar Articles

[PageSpeed] 25

Hi Gina,

You could do this:

At the top of the form's module:

Option Compare Database
Option Explicit
Dim strMyFieldStartValue as String

Then in the forms 'Current' event:

strControlStartValue = Me.MyField

Then, in the before update of MyField

If IsNull(strMyFieldStartValue) Then
rest of your code

Think that would work.
CW

"Gina K" wrote:

> Is this possible to accomplish?
> 
> A field (MyField) contains some text.  When a user changes or deletes that 
> text, I display a message box asking the user if he really wanted to change 
> the text in MyField.  The way my code is set up, the message box displays 
> after every data change.  (I'm not very good at writing code.)
> 
> Dim ChgAnswer As Integer, MsgTitle As String, MsgDialog As Integer
>     Const MB_YESNO = 4
>     Const MB_ICONEXCLAMATION = 48
>     Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
>     
>     If Not IsNull(Me.MyField) Then
>     Beep
>     MsgTitle = "Data Change"
>     MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
>     ChgAnswer = MsgBox("Do you really want to change the data in this 
> field?", MsgDialog, MsgTitle)
>     
>         If ChgAnswer = IDNO Then
>         Me.Undo
>         End If
>     End If
> 
> 
> I want the message box to appear ONLY if MyField already contained a value.  
> If the field was null, I don't want the message box to display.
> 
> What's the best event to use for this purpose?  (I'm currently using 
> BeforeUpdate.)  Can anyone help clean up my code?
> 
> Thanks very much.
0
Utf
6/23/2007 3:09:00 AM
On Jun 23, 7:25 am, Gina K <G...@discussions.microsoft.com> wrote:
> Is this possible to accomplish?
>
> A field (MyField) contains some text.  When a user changes or deletes that
> text, I display a message box asking the user if he really wanted to change
> the text in MyField.  The way my code is set up, the message box displays
> after every data change.  (I'm not very good at writing code.)
>
> Dim ChgAnswer As Integer, MsgTitle As String, MsgDialog As Integer
>     Const MB_YESNO = 4
>     Const MB_ICONEXCLAMATION = 48
>     Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
>
>     If Not IsNull(Me.MyField) Then
>     Beep
>     MsgTitle = "Data Change"
>     MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
>     ChgAnswer = MsgBox("Do you really want to change the data in this
> field?", MsgDialog, MsgTitle)
>
>         If ChgAnswer = IDNO Then
>         Me.Undo
>         End If
>     End If
>
> I want the message box to appear ONLY if MyField already contained a value.  
> If the field was null, I don't want the message box to display.
>
> What's the best event to use for this purpose?  (I'm currently using
> BeforeUpdate.)  Can anyone help clean up my code?
>
> Thanks very much.

Hi,
Allow me give my thought for this:
On Event Enter of your Control try use:
If Not IsNull(Me.Field) then
   If (msgbox("Do you want to change the data in this field?",
vbYesNo, "Data Change") = vbNo then
   Me.NextControl.SetFocus
   End If
End If
Just air Code, but I used it for my Invoice which the user want to
amend UnitPrice.

HTH
Luan

0
luanhoxung
6/23/2007 3:14:54 AM
Reply:

Similar Artilces:

How can I Show data as a % of Sub Group in a Pivot Table
I want to show a column of data (% of City) as a % of a sub group total. Here's my example of how the pivot table should look: State City Carrier Sq Yards % of City (Sq Yards2) Alabama Birmingham Carrier 1 10 20% Carrier 2 20 40% Carrier 3 10 20% Carrier 4 10 20% Birmingham Total 50 100% Mobile Carrier 1 10 25% Carrier 2 10 25% Carrier 3 1...

Pivot Tables filtering data
Using Excel, I have query(using an ODBC connection) of all customer order detail over a two year time period. The detail for each customer is different in that some customer have multiple orders, and the amount of individual sales parts they order may be 1 or 100. My query gathers detail by order line item. We were able to provide management with comparative sales data. Now that we have shown this report to management, they want three things that I'm unsure how to provide. 1) Customers that are new in the current year2) customers that had orders in both years, 3)customers that ...

How do I plot data on a map in excel
I am using Microsoft office standard 2003. I wish to plot information on a local area map within the Clapham Park area, SW2. Hi, There is no built-in functionality for this. You would need a dedicated Mapping program with UK based information. You can however simulate the chart. If you have an image of the map you could use that as the plotarea pattern. You could then use a xy-scatter graph to plot information over the map. You would have to determine the coordinates by trial and error. Cheers Andy Byron wrote: > I am using Microsoft office standard 2003. I wish to plot informat...

Data Validation Dropdown #4
I don't see the dropdown list on one worksheet. if I copy the cell an paste special Validation to another worksheet, then the dropdown lis shows. Tools/options/show All checked. tried restart PC also. the trouble (dropdown list doesn't show even though Data validatio object is OK) happens only to one worksheet in this one workbook. any one interested to see the workbook with the troubled worksheet ca drop me an email. thanks al -- jliu200 MS programmer for financial industr ----------------------------------------------------------------------- jliu2000's Profile: http://www...

How can I use a form (Excel) to add a column of data to the right.
How can I use a form (Excel) to add a column of data to the right of a list? It's a simple matter to add a column to the left of a list by writing a macro that inserts a column and then pastes the values. However I want to have the data pasted on the right of a list, if only so that I can easily run a chart from it. ...

Can I insert Google Calender data into Publisher document?
How can I configure my Publisher document to use the data from Google Calendar? I would like to use the RSS feed from Google Calendar. Creating an RSS Feed http://blogs.msdn.com/lisawoll/archive/2004/11/19/266972.aspx -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "thpope" <thpope@discussions.microsoft.com> wrote in message news:CB5CDF70-1B8E-45E1-B17B-7D496CD96F36@microsoft.com... > How can I configure my Publisher document to use the data from Google > Calendar? I would like to use the RSS feed from Google C...

Combine data from multiple rows onto one row in separate columns
My table looks like this: Sample_# data1 data2 data3 data4 etc.. 0000001 0.1 0.2 0000001 2.5 0000001 0.5 0000002 0.2 0.2 0000002 3.1 0000003 0.1 0.2 I receive data at different points in time and it thus I end up with multiple sample_#'s and various data columns filled in. I would like to combine all the data for each sample into one row. I would like it to look like this: Sample_# data1 data2 data3 data4 etc.. 0000001 ...

Pivot Table data values
I need make a pivot table using the values as the data. I used to be able to do this, but now it only sums, counts or calculates. Is there a way to return the data values? ...

I've just loaded outlook but it does not display any of my messag
I have just loaded Outlook. It recognises my MSN name but does not display any of my messages, nor my personal mail folders. Is there some sort of initialisation that I need to do to populate the folders ? P.S. I've had the account for 4 years, but have been using Hotmail up until now. are you using the outlook connector? Did you do a send and receive? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlookti...

Leading ' in cell values when data is Exported to Excel 2002
Hello, when exporting data to Excel, all of the cells have a leading ' . Any ideas on how to keep this from happening? I have not seen this with earlier versions of Excel and am experiencing this problem when Exporting data from WinRunner and from MS Access through VBA. Much appreciated, thanks. Hi you may try after importing the following line of code range.value=range.value "Jimmy" wrote: > Hello, when exporting data to Excel, all of the cells have a leading ' . > Any ideas on how to keep this from happening? > > I have not seen this with earlier v...

Log Owner changes of CRM entities
When the owner of a record changes, it's ownership history should be tracked. This would allow visibility and reporting flexibility as well as open the door as an enabler of historical reporting. ie: Order totals by Sales Rep could then be calculated by the Sales Rep who owned the Account at the time of the order, and not just by the current owner of the Account. Options considered: 1. Record the owner change date and previous owner on the record itself using custom code from the onchange event. 2. Create a generic Ownership change log entity where a record is created from the Owne...

compare two tables for mismatch data
I have to do a comparison of two tables. Both tables have the same exact headers. The first table is the standard rates template which is linked from excel. The second table is coming from a query off our AS400 system. So basically we are needing to compare with the standard template vs what was inputted into the system. Basically auditing the work inputting, looking for typos and mismatches. What would be the easiest method to use considering we are having to check about 20 fields. ...

Why is Default Value not working?
Why when I goto a new record the date is blank? Here is the code I'm using? Private Sub PostDate_AfterUpdate() Me.PostDate.DefaultValue = Chr(34) & Me.PostDate & Chr(34) End Sub -- Gator Why not put the default value in table design. Got to Post_Date field in the table and set the defaultvalue there... Besides you are setting a defaultvalue in the after update of the field you want to have a default value? Maybe you should go for 'new' record... -- Maurice Ausum "Gator" wrote: > Why when I goto a new record the date is blank? > Here is the code I...

How do I protect a macro to prevent change ?
I have protection turned on for both the worksheets and the workbook. Even so, the user can open Visual Basic Editor and change the macros. How to I protect the macros from being changed ? In Visual Basic go to tools > vga project properties > protection and you will see a section for pass words Try to keep the same pass for all of your work to make things easy if you need to get back in. cheers Pete -- (][ THIS EMAIL HAS BEEN SCANNED BY NORTON ANTIVIRUS ][) "Keisamcasco" <Keisamcasco@discussions.microsoft.com> wrote in message news:12E280B5-02DB-4F77-AD51-59EC0D...

How do I get a list of data on one sheet into the form on the fir.
I have a timecard form on the first tab of a workbook & the various employee crew combinations on each of the subsequent tabs (each crew on a seperate tab). How do I format the for to get the employee name info from the individual crew tab required? Let me clarify my question - I am trying to use the first tab (the form) as a constant form & just change the employees names in that specific field based on the crew I want to generate the timesheet for. The crew lists are on the sugsequent tabs. I would like to be able to select the crew & print the form with only those emp...

How to carry over date value from one record to the next.
I have searched this site and the internet in search of an answer to this problem but none of the solutions I've found have seemed to help. I have a form that is used for data entry. The first two text boxes are called Supervisor and W/E Date. These two values will remain the same for several dozen entries. I have tried just using CTRL + ' to repeat the data but that is getting quite time consuming as well. How do I automatically carry over the value to the next record once I input the first data in? Any help on this would be much appreciated. -- Message posted via AccessMo...

Option for fields to show up in datasheet view
Hello, Since most people are more familiar with excel then access, my users prefer to see it in datasheet view. However, since it could be too long, anyone can help me how to make an option to show up only field that we can chose in the form. I remember there is a sample of database that has that one, but I do not know where is it now. Please help. Thanks in advance, Frank -- Frank Situmorang Simplest solution might be to set the Visible property of the controls on the form, based on the fields the user wants to see. -- Allen Browne - Microsoft MVP. Perth, West...

sent and received fields
I've just switched from Outlook Express to Outlook 2000. In one of my folders, I have sent and received emails that I want to sort together based on the sent or received date, but all my sent emails sort together because the received field has no value. And the same for the received emails. Is there a way to combine these fields or tell Outlook to sort based on both of them? Do I need to write a VBA macro to accomplish this? Thanks, Michael ...

iisadmpwd change pw gives error
Just cannot get password change to work on Exchange2003 (front-end server) & IIS 6.0 Is this a known issue Any help would be greatly appreciated. It could be that you are not (yet) allow to change your password either because password change is prohibited or because user has to wait for x days before he is allowed to change his password (domain policies). Whenever you reset a password for a user and the 'Cannot change pass before X days' is enforced, the user is not allowed to change it. David. "ss" <anonymous@discussions.microsoft.com> wrote in message news...

Find what control is using a data item
I built a form, then deleted 2 columns from the source table and now I get a popup asking for the value of those 2 columns. The problem is, I don't use those columns so I need to find what on the form is refferencing the deleted columns. I have looked at the control drop down on the properties window and the tab order window and can't find a control with either one of the missing column names. How do I determine what is trying to refference the deleted columns? I found the problem, the column was still referenced in the underlying query that fed the form. "MeSteve"...

OWA - change password
Getting the "Object Required" error, when somebody is trying to change their password through OWA. (Win2003/Ex FE 2003) Any ideas what could be causing this? TIA! / Per Did you follow the steps in: http://support.microsoft.com/kb/297121 ? -- Pablo D. Vernocchi Microsoft Exchange MVP MCSA + M / MCSE + Sec https://mvp.support.microsoft.com/profile=8E94A6C0-F6D9-4686-96D5-04230CC0141F http://www.itpros.com.ar http://www.msglue.org http://msmvps.com/exchangebloglatino "Per Hagstrom" <per.hagstrom@swic.eduNOSPAM> wrote in message news:Ojo%23EozNHHA.1240@TK2...

Default email addresses keep changing.
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: pop I upgraded to version 12.2.4 and every so often the default email addresses that I have chosen, switch to another email address such as the default was Home and is now Office. Even after I change them back, it can change again. <br> This is a problem because when I compose an email, I now have to be very careful which default address appears so that I send the email to the right place! <br> We have more than one Mac. I run Office Business; some use Student/Teacher. Some use S...

Displaying time from 00:00 to 0.00
I want to do the opposite to what I have seen on the forums and convert time back to decimals ( I work on aspreadsheet but it has been passworded so I can't crack it. :) I want to be able to write (van out) (Van back in)(Total Van time) 7.25 11.25 4.00 Can anyone help me please ( or a way to crack passwords):cool: -- North for Short ------------------------------------------------------------------------ North for Short's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=22695 View this thread: http://www.excelforum.com/showthrea...

VLookup #VALUE! error help needed to resolve
The following is the funcation I have: =VLOOKUP(B10,'FA CC Summary Report 1141'!F$9:G$92,2,0) I have all the columns formatted the same; as in the column that the function is using to lookup is text and so is the column for this figure in order to pull back the appropriate answer. I have keyed the data instead of having links. I have replaced the final '0' with TRUE & FALSE then put it back. I have formatted the columns for text and for numbers. But I am getting the #VALUE! error in SOME of the cells NOT all of the cells. I don't know what else to d...

auto fill in data when changing fields
i new to crm 4 and i would like to; once i selected the account i need it to grab the main phone and put it in the phone field, and could you tell me where i need to do this, thanks -- j.hardy you can modify the mappings of the corresponding relationship "moon" wrote: > i new to crm 4 and i would like to; once i selected the account i need it to > grab the main phone and put it in the phone field, and could you tell me > where i need to do this, thanks > -- > j.hardy ...