dbTalk Databases Forums  

How to determine the state of SetWarnings revisited?

comp.databases.ms-access comp.databases.ms-access


Discuss How to determine the state of SetWarnings revisited? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MLH
 
Posts: n/a

Default How to determine the state of SetWarnings revisited? - 09-05-2006 , 08:49 AM






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 topic just a bit further...

I'm wondering if VB receives any event notice
indicating that a confirmation dialog just opened?
That is, can I tell if a confirmation dialog WAS
encountered and then act on it?

Suppose SetWarnings is True, and I run a query
which appends a test record to a test table - can I
capture the event of the confirmation dialog
popping up, so I know afterward that it DID?
Also, can I answer it YES automatically?

Reply With Quote
  #2  
Old   
pietlinden@hotmail.com
 
Posts: n/a

Default Re: How to determine the state of SetWarnings revisited? - 09-05-2006 , 02:23 PM






why not just declare a public variable that stores the value of
SetWarnings and then change it whenever you run a SetWarnings
True/False? Then you can return the value anywhere you want. Sounds
to me like you're making this infinitely harder than it really is.


Reply With Quote
  #3  
Old   
MLH
 
Posts: n/a

Default Re: How to determine the state of SetWarnings revisited? - 09-06-2006 , 08:30 AM



You're right. That would take care of it. Of course, once the code
is written and functional, of course its no more difficult then. I'm
just curious - exploring other avenues.

Thx.

Quote:
why not just declare a public variable that stores the value of
SetWarnings and then change it whenever you run a SetWarnings
True/False? Then you can return the value anywhere you want. Sounds
to me like you're making this infinitely harder than it really is.


Reply With Quote
  #4  
Old   
MLH
 
Posts: n/a

Default Re: How to determine the state of SetWarnings revisited? - 09-06-2006 , 08:33 AM



You guys are both right. I'll go with one of your suggestions.

Thx.

Quote:
Better yet, write a function to do it and always use that function
to change it. E.g., make one optional parameter, and if you supply
the parameter, set it accordingly, and set a static variable
(internal to the function) to match the setting. When you want to
know what the status is, you can call it without the optional
argument and act on the returned value.

This is basically a way of using a function as a property. You could
define a custom property in a class module, but then you'd have to
refer to it as part of the class module. Unless you've alredy got a
class module in place for global settings, I'd go with the function.
However, if you're using a class module for storing and setting the
values of global settings, then it makes more sense to implement
this as a property Let/Get.


Reply With Quote
  #5  
Old   
MLH
 
Posts: n/a

Default Re: How to determine the state of SetWarnings revisited? - 09-06-2006 , 09:54 AM



On a related topic...
In A97, if I click Tools, Options, the Edit/Find tab and
unselect Confirm Record Changes, Confirm Document
Deletions and Confirm Action Querirs - will A97 launch
as if DoCmd.SetWarnings False is in effect?

Or, are there other actions that SetWarnings' setting
modifies the behaviour of as well as these three?

A97 HELP says you can use the SetWarnings action
to turn system messages on or off. However, it does
not mention or imply that SetWarnings False is the same
as unselecting the three checkboxes described above.

I'm just wondering - seeiking opinions.

Reply With Quote
  #6  
Old   
Tim Marshall
 
Posts: n/a

Default Re: How to determine the state of SetWarnings revisited? - 09-06-2006 , 11:14 AM



MLH wrote:

Quote:
I'm wondering if VB receives any event notice
indicating that a confirmation dialog just opened?
That is, can I tell if a confirmation dialog WAS
encountered and then act on it?
Just use the execute method and hadnle errors. If no errors, the
statement was passed.

For example (this air code uses David's dblocal function for the
database variable):

Sub sWhatever()

dim strStage as string 'Stage we're at if error thrown
dim strS as string

on error goto err_proc

'Clear records

strStage = "Deleting Existing Records"
strs = "Delete * from tbl_table"
dblocal.execute strs, dbfailonerror

'Add new records

strStage = "Adding New Records"
strS = "Insert into tbl_table (blah, blah...."
dblocal.execute strs, dbfailonerror

Exit_Proc:

Exit Sub

Err_Proc:

select case err.number
case 13 'type mismatch
msgbox strstage & vbcrlf & vbcrlf & _
"Incorrect data type for field...."
resume exit_proc
case 3022 'PK violation, rejig PK and resume
<code to redo strS>
resume 'Or a msgbox saying stuff related to PK
case else
msgbox "Error " & err.number & " ' & err.description & _
vbcrlf & vbcrlf & "Encountered when " & strStage, _
vbCritical, "Error on Sub Whatever", _
err.helpfile, err.help.context
resume exit_proc
end select

End Sub
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.