473,544 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check Status of SetWarnings

This is probably really simple, but I can't find a thread that
addresses it. Is there any way to evaluate in code whether the
current state of the SetWarnings command is set to True or False? I
have a Public Sub that I want to use from several areas of my
application, and I want to turn off warnings for it, but I don't want
to set warnings back to True if the sub was invoked from another sub
or function where warnings had already been set to False.
Nov 13 '05 #1
13 12069
Your subs and functions that call the public sub should look like:

DoCmd.SetWarnin gs False
Call NameOfPublicSub
DoCmd.SetWarnin gs True

This code will branch to the public sub, execute it and then return to the line
below the Call statement. Therefore, Warnings will always be off when running
the public sub and then will be immediately turned back on when the public sub
is done.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com

"Robert McEuen" <UN**********@y ahoo.com> wrote in message
news:fb******** *************** ***@posting.goo gle.com...
This is probably really simple, but I can't find a thread that
addresses it. Is there any way to evaluate in code whether the
current state of the SetWarnings command is set to True or False? I
have a Public Sub that I want to use from several areas of my
application, and I want to turn off warnings for it, but I don't want
to set warnings back to True if the sub was invoked from another sub
or function where warnings had already been set to False.

Nov 13 '05 #2
Robert McEuen wrote:
This is probably really simple, but I can't find a thread that
addresses it. Is there any way to evaluate in code whether the
current state of the SetWarnings command is set to True or False? I
have a Public Sub that I want to use from several areas of my
application, and I want to turn off warnings for it, but I don't want
to set warnings back to True if the sub was invoked from another sub
or function where warnings had already been set to False.


Since it's not a property, more of a state performed by an action, I
doubt it. You might consider setting a global variable to track it.

Nov 13 '05 #3
It is good coding to return a state to the way you found it, but Access does
not let you read the state of SetWarnings.

Your options are to maintain your own flag, or to avoid using SetWarnings.

If you are running action queries, consider using the Execute method (DAO)
instead of RunSQL. Execute does not pop up the warnings, so there is no need
to toggle SetWarnings. It is also more powerful:
- the dbFailOnError switch lets you opt out if there is an error (such as a
concurrency issue that does not allow the action query to complete);
- you have the option to use a transaction around the whole process for an
all-or-nothing result;
- you can read the number of records affected.

Example:
Dim db As DAO.Database
Dim strSQL As String

Set db = dbEngine(0)(0)
strSQL = "INSERT INTO ...

db.Execute strSQL, dbFailOnError
MsgBox db.RecordsAffec ted " record(s) inserted."

Set db =Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Robert McEuen" <UN**********@y ahoo.com> wrote in message
news:fb******** *************** ***@posting.goo gle.com...
This is probably really simple, but I can't find a thread that
addresses it. Is there any way to evaluate in code whether the
current state of the SetWarnings command is set to True or False? I
have a Public Sub that I want to use from several areas of my
application, and I want to turn off warnings for it, but I don't want
to set warnings back to True if the sub was invoked from another sub
or function where warnings had already been set to False.

Nov 13 '05 #4
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** **************@ freenews.iinet. net.au...
It is good coding to return a state to the way you found it, but Access does not let you read the state of SetWarnings. <snip>
Well, well.
I though it was available under GetOptions / SetOptions, but I must have
been mistaken.
Is there really no collection which can be traversed to find this value?
"8-\
Cheers,
Doug

--
Remove the blots from my address to reply

Nov 13 '05 #5
Let's know if you find one, Doug.

I gave up on SetWarnings in Access 2, for this very reason.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Doug Hutcheson" <do************ *****@nrm.blot. qld.blot.gov.bl ot.au> wrote
in message
news:on******** *******@news.op tus.net.au...
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** **************@ freenews.iinet. net.au...
It is good coding to return a state to the way you found it, but Access

does
not let you read the state of SetWarnings.

<snip>
Well, well.
I though it was available under GetOptions / SetOptions, but I must have
been mistaken.
Is there really no collection which can be traversed to find this value?
"8-\
Cheers,
Doug

Nov 13 '05 #6
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** **************@ freenews.iinet. net.au...
"Doug Hutcheson" <do************ *****@nrm.blot. qld.blot.gov.bl ot.au> wrote
in message
news:on******** *******@news.op tus.net.au...
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** **************@ freenews.iinet. net.au...
It is good coding to return a state to the way you found it, but
Access does
not let you read the state of SetWarnings.

<snip>
Well, well.
I though it was available under GetOptions / SetOptions, but I must have
been mistaken.
Is there really no collection which can be traversed to find this value?
"8-\
Cheers,
Doug

Let's know if you find one, Doug.

I gave up on SetWarnings in Access 2, for this very reason.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


OK all you MVPs: what API needs to be called to read this value? It's gotta
be there somewhere in order to have effect!
<I never give up without a drink ... er ... fight ... >
"8-]

--
Remove the blots from my address to reply
Nov 13 '05 #7
Doug Hutcheson wrote:
Let's know if you find one, Doug.

I gave up on SetWarnings in Access 2, for this very reason.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

OK all you MVPs: what API needs to be called to read this value? It's gotta
be there somewhere in order to have effect!
<I never give up without a drink ... er ... fight ... >
"8-]


Just as you can "set warning False" in a form by simply entering
Response = acdataerrcontin ue
in the forms' OnError event, I would think there is a flag somewhere
within access that gets set that when running a query or whatever tells
the system not to display a message. Instead of an API, I guessing the
flag gets set somewhere in a system table.
Nov 13 '05 #8
"Doug Hutcheson" <do************ *****@nrm.blot. qld.blot.gov.bl ot.au> wrote
in message news:_C******** *******@news.op tus.net.au...
OK all you MVPs: what API needs to be called to read this value? It's gotta be there somewhere in order to have effect!


I'm not an MVP but ...
The OP can get around his problem by using:

Application.Set Option "Confirm Action Queries", False
DoCmd.RunSQL "UPDATE table1 (etc)"
Application.Set Option "Confirm Action Queries", True

This preserves the SetWarnings state for when the Option is set back to
True.
Also, by setting the Option to False its overrides any previous SetWarnings
= True such that no warnings are given.

Ian Hinson.
Nov 13 '05 #9
However, this will break any user who had that setting as being False
already themselves?
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Ian Hinson" <pp******@bigpo nd.net.au> wrote in message
news:0W******** *********@news-server.bigpond. net.au...
"Doug Hutcheson" <do************ *****@nrm.blot. qld.blot.gov.bl ot.au> wrote
in message news:_C******** *******@news.op tus.net.au...
OK all you MVPs: what API needs to be called to read this value? It's gotta
be there somewhere in order to have effect!


I'm not an MVP but ...
The OP can get around his problem by using:

Application.Set Option "Confirm Action Queries", False
DoCmd.RunSQL "UPDATE table1 (etc)"
Application.Set Option "Confirm Action Queries", True

This preserves the SetWarnings state for when the Option is set back to
True.
Also, by setting the Option to False its overrides any previous

SetWarnings = True such that no warnings are given.

Ian Hinson.

Nov 13 '05 #10

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

Similar topics

2
3742
by: Craig M | last post by:
Hi, I have a form, frmInvoices and a subform, frmInvoicesSub. On the parent form, i have a "print report" button, that prints a report depending on an ID on the parent form. Each record in the subform has a check box, "invoiced". Currently, my print report button has the folowing code:
2
3343
by: Cassie Pennington | last post by:
Is there a command to spell check fields in Access (probably in the afterupdate event)? Thanks in anticipation Cassie
1
2655
by: Jim M | last post by:
To prevent data corruption I have replaced a memo field on my form with an unbound control on my form that I populate with a function that fills it from a memo field from my table. When the form is closed, another function in a query writes it to the memo field. No trouble. When I run spell check on the form it makes the corrections in the...
2
6923
by: RLN | last post by:
Re: Access 2003 I have code to check to see if a table exists. There are several other tables (tblQ12, tblQ13, etc) that do already exist & this code runs fine; msgbox says the value returned is true when the table already exists prior to the run of this module. If the table does not exist, this line bombs varTemp =...
3
8773
by: jsurkin | last post by:
I have a form that lists a single work request, with an attached continuous subform that lists specific items that are part of the request. Each item in the subform has a check box to indicate when the work is completed, along with a date text box to indicate when the work was completed. There is also a check box and corresponding date field...
10
4807
by: Cliff72 | last post by:
Is there a way in VBA to check if a linked table in the database has been updated? Example: I have a table "LedgerTemp" which is a direct link to a text file on the LAN "Ledger.txt" This text file is periodically updated (overwritten) through out the day and night by some mainframe jobs. Right now I just manually run a macro that just...
5
1919
by: MLH | last post by:
Access 97 does not provide a means of reading the most recent setting for SetWarnings Method. For example, if you had CBF that called a procedure in a global module and the following statement was executed: DoCmd.SetWarnings False Then you would not be able to take peek at the setting when processing returned to the calling
1
3167
by: Lynx101 | last post by:
I've got the following code to work, but the problem is that it is check all fields on every record. Is there a way to make this work on one particular field AND only the current record? Dim strSpell strSpell = YOURFIELDNAME If IsNull(Len(strSpell)) Or Len(strSpell) = 0 Then Exit Sub End If
5
13119
by: Laetitia | last post by:
Hi All Please can anyone advise whether it is possible to display messages in the status bar. I have a number of update queries which will be run and need to find a way to identify which field is currently being updated so that I can monitor the progress. I know that I can use InputBox to display the variable table and field
0
7434
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7622
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5925
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4925
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3425
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3420
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
676
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.