473,473 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get the value of SetWarnings

Hello,

I am suppressing the warnings in Ms Access database by using the
DoCmd.SetWarnings=False statement. However I want to get a list of all
the Warnings that were generated between a:

DoCmd.SetWarnings False and DoCmd.SetWarnings True

Please Suggest.

Thanks and Regards,
Pradeep Varma

*** Sent via Developersdex http://www.developersdex.com ***
Jun 7 '06 #1
12 5861
Unfortunatly, Access does not expose this value.

You could create a public variable and track it yourself, but it is much
better to use the Execute method, since it:
a) does not need to turn SetWarnings off;
b) can give you an indication of the action query fails to complete;
c) can give you an indication of the number of records affected;
d) can be used in a transaction to get an all or nothing result.

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

"Pradeep Varma" <pr***********@rediffmail.com> wrote in message
news:rW*************@news.uswest.net...
Hello,

I am suppressing the warnings in Ms Access database by using the
DoCmd.SetWarnings=False statement. However I want to get a list of all
the Warnings that were generated between a:

DoCmd.SetWarnings False and DoCmd.SetWarnings True

Jun 7 '06 #2
I am sorry I did not get you. How could I keep track of it using a
public variable if Access does not expose it. I request you to provide
me an insight into how i could track the value using a public variable
as it does not go into the error handler too.

Cheers,

Pradeep Varma

*** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #3
Set your variable every time you change SetWarnings.

Example:
Public bWarnings As Boolean
Public Function DoSetWarning(bOn as Boolean)
DoCmd.SetWarnings bOn
bWarnings = bOn
End Function

You can now test bWarnings anywhere, provided all your code toggles this
setting via your function.

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

"Pradeep Varma" <pr***********@rediffmail.com> wrote in message
news:YL**************@news.uswest.net...
I am sorry I did not get you. How could I keep track of it using a
public variable if Access does not expose it. I request you to provide
me an insight into how i could track the value using a public variable
as it does not go into the error handler too.

Jun 8 '06 #4
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:44***********************@per-qv1-newsreader-01.iinet.net.au:
Set your variable every time you change SetWarnings.

Example:
Public bWarnings As Boolean
Public Function DoSetWarning(bOn as Boolean)
DoCmd.SetWarnings bOn
bWarnings = bOn
End Function

You can now test bWarnings anywhere, provided all your code
toggles this setting via your function.


Seems to me that this would be a perfect case for a custom property
Let/Get, and make the variable private.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 8 '06 #5
It seems to me that the OP was not asking about tracking the value of
WarningsOn, but rather wanting information programmatically about what
warnings would have been generated if WarningsOn had been true.

Edward

Jun 8 '06 #6
You could be right.

If that was the question, Access does not expose those warning messages to
you. You need to use another approach to be able to read those messages,
such as the Execute method in my first reply.

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

<ed****@paleo.org> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
It seems to me that the OP was not asking about tracking the value of
WarningsOn, but rather wanting information programmatically about what
warnings would have been generated if WarningsOn had been true.

Edward

Jun 9 '06 #7

Oh, I got what you mean but in my case we have a huge procedure which
calls many other procedures. A SetWarning False is there at the begining
and a SetWarning True at the end of this huge procedure. So this does
not really apply to me. I should be able to get the value of
SetWarnings, i guess.

Thanks for the help.

Pradeep Varma
*** Sent via Developersdex http://www.developersdex.com ***
Jun 9 '06 #8
I don't understand why you can't include the previous code, and replace the
line:
DoCmd.SetWarnings False
at the top of that procedure with:
Call DoSetWarning(False)
Then at the end of the procedure, replace:
DoCmd.SetWarnings True
with:
Call DoSetWarning(True)

If you did that consistently in your application, you could read the value
of:
bWarnings
anywhere you want.

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

"Pradeep Varma" <pr***********@rediffmail.com> wrote in message
news:pz****************@news.uswest.net...

Oh, I got what you mean but in my case we have a huge procedure which
calls many other procedures. A SetWarning False is there at the begining
and a SetWarning True at the end of this huge procedure. So this does
not really apply to me. I should be able to get the value of
SetWarnings, i guess.

Jun 9 '06 #9
I got your suggestions and Execute can be used to execute the action
queries and does give us a good control on the data. However thats not
my requirement. As i told to you the SetWarnings is set to False in the
begining of the procedure and is again set to True at the end. In
between there are a variety of things happening like execution of
queries, a few TransferSpreadsheet commands and some OutputTo commands.
Now I want to keep track of the warnings generated if any behind the
scenes during the execution of the procedure. Thanks for the help.

Pradeep Varma
*** Sent via Developersdex http://www.developersdex.com ***
Jun 9 '06 #10
Hi,

Thanks a lot for the quick responses. While I understand that Execute
method offers more control over the data, my procedure contains a lot of
TransferSpreadsheet statements, a few of action queries and some
OutputTo commands.I just wanted to know if there is any way using which
I could read the warning messages that might have been generated during
a :

DoCmd.SetWarnings False
and a

DoCmd.SetWarnings True

Thanks a lot for your help.

Regards

Pradeep Varma

*** Sent via Developersdex http://www.developersdex.com ***
Jun 9 '06 #11
Pradeep Varma <pr***********@rediffmail.com> wrote in
news:pz****************@news.uswest.net:
Oh, I got what you mean but in my case we have a huge procedure
which calls many other procedures. A SetWarning False is there at
the begining and a SetWarning True at the end of this huge
procedure. So this does not really apply to me. I should be able
to get the value of SetWarnings, i guess.


That's bad coding. It basically shows that the code is using direct
UI methods instead of the preferred code methods. For instance, if
you're using DoCmd.OpenQuery instead of CurrentDB().Execute to run
action queries, you'll have to turn off warnings. If you did it
right, with Execute, you'd not need to turn off any warnings, though
you'd need an error handler to deal with any errors that happened
(since you'd want to execute your SQL with the dbFailOnError
option).

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 9 '06 #12
Pradeep Varma <pr***********@rediffmail.com> wrote in
news:jP************@news.uswest.net:
I got your suggestions and Execute can be used to execute the
action queries and does give us a good control on the data.
However thats not my requirement. As i told to you the SetWarnings
is set to False in the begining of the procedure and is again set
to True at the end. In between there are a variety of things
happening like execution of queries, a few TransferSpreadsheet
commands and some OutputTo commands. Now I want to keep track of
the warnings generated if any behind the scenes during the
execution of the procedure.


Then get rid of all the Setwarnings False and implement proper error
handling.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 9 '06 #13

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

Similar topics

10
by: Colleyville Alan | last post by:
I am trying to turn a short and fat (63 columns) table into one that is tall and skinny (7 columns). Basically, I am trying to create a "reverse crosstab" using a looping structure in VBA along...
3
by: tdmailbox | last post by:
I have a function that hashs the value that a user entered in a text box and stored that hash value as a password. All is well unless a user enters a password that when hased has a ; in it. If...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
4
by: Pman12 | last post by:
Below is the vba code I am working with. When it gets to the insert part I get an "Enter parameter value" dialog box with the value of the variable "id" above the cursor. I have to type in that...
5
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...
1
by: natural | last post by:
Good Afternoon I have an option grou[ and on the after update i would like to provide the user with a msgbox, and then action placed my docmd.setwarnings false everywhere, but i still get my...
10
by: Steve Eslinger | last post by:
I have a query that I built using VB. It takes parameters that I pass in from a form and inserts records into a table. The problem I have is some of the values I enter cause the query to timeout. ...
7
by: adigga1 | last post by:
Hello EveryOne, I have a situation with a Form running an event; It works fine when it calls or manipulates number values; but when I put a character within the numbers or use alpha-numeric...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.