By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Get the value of SetWarnings

P: n/a
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
Share this Question
Share on Google+
12 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.