473,324 Members | 2,400 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,324 software developers and data experts.

What would you recommend as a harmless test to determine state of SetWarnings in A97

MLH
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
procedure. You'd simply have to run the Method
there again to make sure the setting is what you
want it to be from that point forward.

I'm not saying there's anything wrong with that.
One can simply adapt. What is unhandy about not
being able to read the setting? Well, if you are
deliberately trying to identify and correct instances
where the setting is not what you intended for it to
be after calling some saved procedure.

I'd like to have a procedure that did something
trivial - something with no adverse effect that
when called, would do something that could
determine the setting - indirectly perhaps. Then
I could sprinkle my code with calls to this procedure
as liberally as I wanted. At some point I would be
satisfied, I'm sure, that SetWarnings settings made
in called procedures did not leave things in an
unexpected state upon return to the calling
procedure.
Mar 12 '08 #1
5 1899
On Tue, 11 Mar 2008 21:10:26 -0400, MLH <CR**@NorthState.netwrote:

Simple: in a standard module create this:
private m_blnWarningState as Boolean
public sub SetWarningsOff()
docmd.SetWarnings False
m_blnWarningState = False
end sub
public sub SetWarningsOn()
docmd.SetWarnings True
m_blnWarningState = True
end sub
public function GetWarningState() as Boolean
GetWarningState = m_blnWarningState
end function

-Tom.

>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
procedure. You'd simply have to run the Method
there again to make sure the setting is what you
want it to be from that point forward.

I'm not saying there's anything wrong with that.
One can simply adapt. What is unhandy about not
being able to read the setting? Well, if you are
deliberately trying to identify and correct instances
where the setting is not what you intended for it to
be after calling some saved procedure.

I'd like to have a procedure that did something
trivial - something with no adverse effect that
when called, would do something that could
determine the setting - indirectly perhaps. Then
I could sprinkle my code with calls to this procedure
as liberally as I wanted. At some point I would be
satisfied, I'm sure, that SetWarnings settings made
in called procedures did not leave things in an
unexpected state upon return to the calling
procedure.
Mar 12 '08 #2
Since Access does not provide a way to test this setting, Tom's suggestion
makes good sense.

A more fundamental question might be why you need to set this. IME, people
turn this off to suppress the messages when running action queries. That's
not a good idea: you have no idea whether the action query worked or ran
into errors.

A better solution (which avoids the need to mess with SetWarnings) might be
to use Exeucte with the action query:
http://allenbrowne.com/ser-60.html

--
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.

"Tom van Stiphout" <no*************@cox.netwrote in message
news:dq********************************@4ax.com...
On Tue, 11 Mar 2008 21:10:26 -0400, MLH <CR**@NorthState.netwrote:

Simple: in a standard module create this:
private m_blnWarningState as Boolean
public sub SetWarningsOff()
docmd.SetWarnings False
m_blnWarningState = False
end sub
public sub SetWarningsOn()
docmd.SetWarnings True
m_blnWarningState = True
end sub
public function GetWarningState() as Boolean
GetWarningState = m_blnWarningState
end function

-Tom.

>>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
procedure. You'd simply have to run the Method
there again to make sure the setting is what you
want it to be from that point forward.

I'm not saying there's anything wrong with that.
One can simply adapt. What is unhandy about not
being able to read the setting? Well, if you are
deliberately trying to identify and correct instances
where the setting is not what you intended for it to
be after calling some saved procedure.

I'd like to have a procedure that did something
trivial - something with no adverse effect that
when called, would do something that could
determine the setting - indirectly perhaps. Then
I could sprinkle my code with calls to this procedure
as liberally as I wanted. At some point I would be
satisfied, I'm sure, that SetWarnings settings made
in called procedures did not leave things in an
unexpected state upon return to the calling
procedure.
Mar 12 '08 #3
On Wed, 12 Mar 2008 22:24:29 +0900, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:

I agree. The only positive thing about DoCmd.RunSQL and its cousins is
that they provide a progress meter, whereas .Execute does not.

Don't forget to run .Execute with the dbFailOnError flag, in most
cases.

-Tom.

>Since Access does not provide a way to test this setting, Tom's suggestion
makes good sense.

A more fundamental question might be why you need to set this. IME, people
turn this off to suppress the messages when running action queries. That's
not a good idea: you have no idea whether the action query worked or ran
into errors.

A better solution (which avoids the need to mess with SetWarnings) might be
to use Exeucte with the action query:
http://allenbrowne.com/ser-60.html
Mar 12 '08 #4
On Mar 11, 9:10*pm, MLH <C...@NorthState.netwrote:
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
procedure. You'd simply have to run the Method
there again to make sure the setting is what you
want it to be from that point forward.

I'm not saying there's anything wrong with that.
One can simply adapt. What is unhandy about not
being able to read the setting? Well, if you are
deliberately trying to identify and correct instances
where the setting is not what you intended for it to
be after calling some saved procedure.

I'd like to have a procedure that did something
trivial - something with no adverse effect that
when called, would do something that could
determine the setting - indirectly perhaps. Then
I could sprinkle my code with calls to this procedure
as liberally as I wanted. At some point I would be
satisfied, I'm sure, that SetWarnings settings made
in called procedures did not leave things in an
unexpected state upon return to the calling
procedure.

private bWarningState as Boolean

public sub ToggleWarningState(bState as boolean)
DoCmd.SetWarnings bState
bWarningState = bState
end sub

public function CurrentWarningState() as Boolean
CurrentWarningState = bWarningState
end function

Similar to above with less code. Shoudl work just fine.
Mar 12 '08 #5
On Wed, 12 Mar 2008 07:15:29 -0700, Tom van Stiphout <no*************@cox.net>
wrote:
>On Wed, 12 Mar 2008 22:24:29 +0900, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:

I agree. The only positive thing about DoCmd.RunSQL and its cousins is
that they provide a progress meter, whereas .Execute does not.

Don't forget to run .Execute with the dbFailOnError flag, in most
cases.

-Tom.
I agree .Execute is generally the preferred method, however because DoCmd.RunSQL
is executed via the Access expression service rather than the Jet expression
service (used by Execute), their are instances where an SQL string will fail
using .Execute but will suceed using RunSQL.

Notably DoCmd.RunSQL can usually handle calls to custom functions within the SQL
string without having to concatenate the result of the function into the string
first.
Wayne Gillespie
Gosford NSW Australia
Mar 12 '08 #6

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

Similar topics

12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
3
by: Odd Bjørn Andersen | last post by:
Every night at 21.30 we perform a full offline database backup. Just before the backup starts we do a db2stop/db2start. After the db2stop there is a message in the db2diag.log, and after the backup...
3
by: Rod | last post by:
In Dino Esposito's book, "Programming Microsoft ASP.NET", there is a chapter titled, "ASP.NET State Management". There is a section in there discussing session state sometimes going away. He...
10
by: MLH | last post by:
I thought I could run docmd.SetWarnings in the immediate window with no argument and A97 would return True or False, depending on the current setting. I was wrong. Anybody know how to make the...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
6
by: MLH | last post by:
In my Tues, Mar 21 2006 original post on this topic, Allen Browne made a very good case for use of the Execute method instead of firing an action query with RunSQL or OpenQuery. Ex- ploring the...
82
by: quiberon2 | last post by:
Hi, Sorry if it might be a stupid question but what should returns malloc(0) ? void *ptr = malloc(0); I am running gcc 3.3.5 and a non-null address is returned. ( in the compiler that I am...
14
by: salad | last post by:
XML seems to be a hot technology buzzword. And it appears XML is supported in A2003. I am wondering if it could be used in the following scenario. I create an order record for the customer. ...
48
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.