473,385 Members | 1,397 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,385 software developers and data experts.

How can I intercept and modify the system warning message

kcdoell
230 100+
Hello:

I have a continuous form where the user can add records. One of the fields “Binding_Percentage” is a required field, so if left blank the user will receive the following message:

“The field ‘tblAllForecast.Binding_Percentage” cannot contain a Null value because the required property for this field is set to True. Enter a value in this field.”

I would like to customize this message so that it is more meaningful to the End User. How would I go about doing that via VB?

Any help would be appreciated.

Keith.
Mar 25 '08 #1
9 2520
kcdoell
230 100+
Any thoughts out there on this topic???
Mar 27 '08 #2
Hi there,

Not sure if this is what you're after, but in the properties of the text box in the Validation Text Box you could type your message to your user, like this

Validation Rule : Is not Null
Validation Text : Please Enter A Value


This would then throw up a warning box with your personal message. Hope this helps.

Mark
Mar 28 '08 #3
Scott Price
1,384 Expert 1GB
Alternatively a strict VBA solution would require you to set the warnings false before the error occurs, then in your error trapping mechanism calling a message box with your custom error message.


Regards,
Scott
Mar 28 '08 #4
kcdoell
230 100+
Scott:

I would like to use your idea but never tried it before. Below is my code that executes when a new record is created. :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. 'When a user is creating a new record the following code inserts the MonthID, YearID and
  3. 'The LocationsID.  It does a Dlookup for the Locations ID when the control cboLocation is
  4. 'blank.
  5.  
  6. Dim frm As Form
  7.  
  8. Set frm = Forms!Forecast
  9.  
  10. If Me.NewRecord Then
  11.   'If cboLocation is Not Null, grab the value from there
  12.   If Not IsNull(frm![cboLocation]) Then
  13.     JtnLocationsID = frm!cboLocation
  14.     YearID = frm!CboYear
  15.     MonthID = frm!CboMonth
  16.   Else      'Forms!Forecast![cboLocation] is Null
  17.     'Check and see if all 3 Controls have values in them
  18.     If Not IsNull(frm![cboDivision]) And Not IsNull(frm![cboWrkReg]) And _
  19.        Not IsNull(frm![cboCreditReg]) Then       'values in all 3 Controls
  20.          JtnLocationsID = DLookup("[JtnLocationsID]", "tblLocationsMM", "[DivisionIDFK] =" & frm![cboDivision] & _
  21.                           " And [WrkRegIDFK] =" & frm![cboWrkReg] & " And [CreditRegIDFK] =" & _
  22.                           frm![cboCreditReg])
  23.          YearID = frm!CboYear
  24.          MonthID = frm!CboMonth
  25.     Else
  26.       'no value in [cboLocation], and 1 or more values are missing in [cboDivision],
  27.       '[cboWrkReg], or [cboCreditReg]
  28.  
  29.       MsgBox "1 or more values are missing in"
  30.  
  31.     End If
  32.   End If
  33. End If
  34. End Sub
  35.  
The control that is required on my form is called "Binding_Percentage". Where would I incorporate and "error catch" and what would be the verbiage in vb?

Any help would be great.

Thanks for the reply,

Keith
Mar 28 '08 #5
Scott Price
1,384 Expert 1GB
It would be a good idea for you to read through some threads dealing with error handling in VBA. This is a link to Allen Browne's page on error handling. I personally use his error logging code.

However, to give you a brief overview:

On line 2 of your code you will have something like this:

Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_Form_BeforeUpdate
At the end of your code block (just before the End Sub) you'll have:

Expand|Select|Wrap|Line Numbers
  1. Exit_Form_BeforeUpdate:
  2. Exit Sub
  3. Err_Form_BeforeUpdate:
  4. MsgBox Err.Description & " " & Err.Number, vbCritical
  5. Resume Exit_Form_BeforeUpdate
  6.  
Obviously you can make the MsgBox say anything you want, including setting it's title, etc... There really isn't any need to set the warnings false, since this will suppress the default error message by itself, however, for future information the command to do so is:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings = False
Don't forget to set them on again before you exit the sub routine:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings = True
Regards,
Scott
Mar 28 '08 #6
isoquin
48
First I'll say I'm by no means an Access expert, but I have encountered this and came up with my own solution.

You can have your form's "BeforeUpdate" event check for the field first.
Expand|Select|Wrap|Line Numbers
  1. if isNull(myVariable) Then
  2.    MsgBox ("your own error here")
  3.    Cancel = True
  4. Else: Cancel = False
  5. End If
Again, I'm no expert like some of the other pros here, but giv eit a shot.
Mar 28 '08 #7
kcdoell
230 100+
Thanks I will try that and get back to you both.

Keith.
Mar 28 '08 #8
kcdoell
230 100+
Both ideas worked great!

Thank you,

Keith.
Mar 28 '08 #9
Scott Price
1,384 Expert 1GB
Good call Isoquin! The reason to use the BeforeUpdate event in the first place is for data validation, which includes whether required fields are left blank.

Testing for a null value is 'best practice' :-) In addition to error handling for unexpected occurrences.

Glad it's working for you!

Regards,
Scott
Mar 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
1
by: Morten Overgaard | last post by:
Hi all Is it possible for a .Net app. to intercept the "open" action on files in a given directory. I want to intercept the "open" action and the perhaps direct the client ( the app. which is...
1
by: Imran | last post by:
Hi, Please bear with me as I have only 1 weeks .NET experience. I am using VB.NET to write a stand-alone client application that connects to a Web service. I successfully send a request for a...
0
by: zoltix | last post by:
Hi, I am beginner in aspx. I would like to intercept all click events on my document. I use this function in javascipt for that document.onmousedown=click;. It works well. But I would...
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
5
by: LP | last post by:
Hi, After html of .aspx page has been generated, but before it has been sent to a client, I want to interecept it, and slightly modify it. I can't find anyway to get html of a page. How can I do...
1
by: Ondrej Dobias | last post by:
Hello, I would like to intercept WebBrowser's HTTP requests in order to be able to supply custom login to the proxy server, as well as choose the right certificate for several specific sites. I'm...
8
by: RJ45 | last post by:
Hello, I am writing a shell in C. I need to intercept Signals like CTRL+C or CTRL+D and set to ignore them. This is on Unix, using gcc. my goal is to avoid users escaping the shell with SIGINT...
0
by: rsiena | last post by:
When a page is requested in the .net architecture I believe there are a number of events that happen prior to .net actually trying to find the page in the file system. I would like to intercept...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.