473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to determine the state of SetWarnings revisited?

MLH
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?
Sep 5 '06 #1
6 2260
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.

Sep 5 '06 #2
pi********@hotmail.com wrote in
news:11**********************@b28g2000cwb.googlegr oups.com:
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.
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.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 5 '06 #3
MLH
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.
>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.
Sep 6 '06 #4
MLH
You guys are both right. I'll go with one of your suggestions.

Thx.
>
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.
Sep 6 '06 #5
MLH
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.
Sep 6 '06 #6
MLH wrote:
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
Sep 6 '06 #7

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

Similar topics

2
by: Hunter Hillegas | last post by:
I cannot determine what character is stored in a varchar... For instance: thedonnaholics=# select state from mailing_list where rec_num = 7; state ------- (1 row) If I then execute:
5
by: DC Fan | last post by:
Hi all... Been a while since had a question here, but I can not find a single thing about this in the group or even on the whole web! My Access XP application is running some stored queries and...
10
by: MLH | last post by:
I thought I could run docmd.SetWarnings in the immediate window with no argument and A97 would return True or False, depending on the current setting. I was wrong. Anybody know how to make the...
12
by: Pradeep Varma | last post by:
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: ...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
9
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane...
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.