Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Warning Status 1

Status
Not open for further replies.

KornGeek

Programmer
Aug 1, 2002
1,961
US
I'm using Access 2000. In my code, I often use the DoCmd.SetWarnings command to turn warnings off before running queries, and then to turn them back on again afterward. Is there a way to programatically determine if warnings are currently enabled or disabled?

I have a subroutine that runs a query, and I would like to have warnings off before the query runs, and then have the status revert to what it was before the subroutine was called. I don't want the subroutine to leave the warnings disabled if I'm expecting them to be there, but I don't want it to enable them if they were already disabled.

My subroutine is tied to a timer event, so I can't be certain of which status will be set prior to calling it. If there is no way to do this, then I will have to simply turn warnings off and do all of my own when appropriate, but I'd prefer not to go that route.

Any help you can offer is appreciated.
[morning] Sleep is for people with no caffeine.
 
I don't know of any way to read the status but if you are not too far along in your code development you could create public functions something like these in a standard module:

In the declarations area at the top of the module

Private mblnSetWarnings

Public Sub SetWarnings(bValue As Boolean, _
Optional obSetGlobalValue As Boolean = True)
If obSetGlobalValue Then
mblnSetWarnings = bValue
End If
DoCmd.SetWarnings bValue
End Sub 'SetWarnings

Public Sub ResetWarnings()
DoCmd.SetWarnings mblnSetWarnings
End Sub 'ResetWarnings

In regular processing you would call SetWarnings to set it the way you needed it to be set. Whether or not you called ResetWarnings would depend on your processing requirements.

In your timer event you would call SetWarnings with the optional second parm set to False so that the module level variable would not be changed. Then call ResetWarnings to reset the status at the end of your timer event.

Good Luck!
 
Wow, good idea. It seems so simple when looking at it, yet the thought never occurred to me. I think I'm frying a few too many brain cells dealing with user-level security and my copy protection scheme.

Thanks a lot. Have a star. [morning] Sleep is for people with no caffeine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top