473,698 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2274
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********@hotm ail.com wrote in
news:11******** **************@ b28g2000cwb.goo glegroups.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.SetWarnin gs 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 & "Encountere d when " & strStage, _
vbCritical, "Error on Sub Whatever", _
err.helpfile, err.help.contex t
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
1460
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
683
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 some SQL statements and I am using DoCmd.Setwarnings False to turn off the default "Are you sure" warnings in Access. When it hit's certain setwarning commands, it gives the error dialog in the subject of this post. An example of my code follows....
10
7213
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 determination in the immediate window?
12
5885
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: DoCmd.SetWarnings False and DoCmd.SetWarnings True Please Suggest.
7
16935
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 write an helper method that will tell if the socket is connected or not , but it's not working good continue to tell me that the socket is connectedeven if the other party already call shutdown(both) + close , or , even if the other party close the...
9
2679
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 T. Smith" "Fred Barzowsky" "Department of Oncology" "Office of Student Affairs" "Lewis Hall" etc. etc. etc. I am wondering what the efficient way to do this in code might be. The dumb and brute-force way would be to loop through the content...
16
3501
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
5
1930
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 executed: DoCmd.SetWarnings False Then you would not be able to take peek at the setting when processing returned to the calling
1
3078
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 "record has been deleted". Is i possilbe to please assist in where i am going wrong Private Sub RecOffLet_AfterUpdate() On Error GoTo Err_Handler
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.