docmd.SetWarnings ac 97 status

E

egerds

How does on return what the true/false 0 or -1 of current status
docmd.SetWarnings in access 97?

like a
dim byt_X as byte
byt_X = SetWarnings(?).?
without the docmd
 
M

Marshall Barton

egerds said:
How does on return what the true/false 0 or -1 of current status
docmd.SetWarnings in access 97?

like a
dim byt_X as byte
byt_X = SetWarnings(?).?
without the docmd


Dumb, but there's no way to get that status.

I suppose you could create a function or two to keep track
of it, but I wouldn't bother.

OTOH, you should stay away from methods that generate those
warning messages. Instead, use other methods that allow you
to use error trapping (OnError GoTo ,,,)
 
A

Allen Browne

As Marshall says, Access doesn't provide the status of SetWarnings to you.

What are you doing that requires you to set/know this?
There may be a better way, e.g.:
Action queries: suppressing dialogs, while knowing result
at:
http://allenbrowne.com/ser-60.html

In the end, you could create a public variable in a standard module (not
that of a form or report), and set/read it as required. This kind of thing:
Public bWarningsOff As Boolean
Function SetTheWarnings(bWarning as Boolean) As Boolean
bWarningsOff = bWarning
DoCmd.SetWarnings bWarning
SetTheWarnings = bWarning
End Sub
Function GetTheWarnings() As Boolean
GetTheWarnings = bWarningsOff
End Function

Then you use SetTheWarnings instead of DoCmd.SetWarnings. In your app's
initializations, include:
Call SetThwWarnings(False)
so that the variable and actual state match when the database opens.

The main trouble with this is that the public variable is reset to False
when you reset your code, as you frequently do during development.
 
E

egerds

Nothing personally, it was asked by a coworker of mine. I prefer not
to use docmd myself but db.execute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top