Application.SetOption "Confirm Action Queries", 0

D

DawnTreader

when i set this to stop the annoying popups can i leave it set that way for
my app by doing it on the open of my "first" form, the first one the user
sees, and then close it off on the close of my "last" form, the one where the
user closes out the app?

or do i need to do it for every new form the user sees, where i dont want
the confirmations?
 
J

John Spencer

You set the value for the entire application, not for one specific form.

I would avoid doing this. If you can show us the code that is causing the
problem, we might be able to point out alternatives that won't cause the
"annoying" messages to pop up all the time.

For instance using the following code will not trigger the warning message.
StrSQL = "Update TableA Set Field1 = 5"
Currentdb().Execute strSQL, dbFailonError

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
D

DawnTreader

Hello

it is not really causing a problem but here is the code:

Private Sub Form_Close()

Dim NetworkLoginName As String
Dim DBLoginId As Integer
Dim DBLoginType As String

NetworkLoginName = fOSUserName()

DBLoginId = DLookup("ROWID", "dbo_EMPLOYEE", "UserNameID = '" &
NetworkLoginName & "'")

DoCmd.RunSQL "INSERT INTO tblLoginLog (EmployeeId, Type) VALUES (" &
DBLoginId & ", 'Out')"

Call toolbarson

Application.SetOption "Confirm Action Queries", 1
Application.SetOption "Confirm Document Deletions", 1
Application.SetOption "Confirm Record Changes", 1

End Sub

this is the last code that would run when the user closes out of the app.
the username and date is being put into a table with the sql here so that i
can tag the log out. the problem is that it will sometimes, not all the time,
tell me it is about to "update 1 row, am i sure?"

i would like to make sure that this doesnt happen.

basically i want something to update my login table, then close the app.
 
T

Tony Toews [MVP]

DawnTreader said:
when i set this to stop the annoying popups can i leave it set that way for
my app by doing it on the open of my "first" form, the first one the user
sees, and then close it off on the close of my "last" form, the one where the
user closes out the app?

I would strongly recommend you not use docmd.runsql at all.

I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql. For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText

If you're going to use docmd.setwarnings make very sure you put the
True statement in any error handling code as well. Otherwise weird
things may happen later on especially while you are working on the
app. For example you will no longer get the "Do you wish to save your
changes" message if you close an object. This may mean that unwanted
changes, deletions or additions will be saved to your MDB.

Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
J

John Spencer

Private Sub Form_Close()
Dim dbAny as DAO.Database

Dim NetworkLoginName As String
Dim DBLoginId As Integer
Dim DBLoginType As String

NetworkLoginName = fOSUserName()

DBLoginId = DLookup("ROWID", "dbo_EMPLOYEE", "UserNameID = '" &
NetworkLoginName & "'")

Set dbAny = Currentdb()
dbAny.Execute "INSERT INTO tblLoginLog (EmployeeId, Type) " & _
VALUES (" & DBLoginId & ", 'Out')"

Then you don't need to turn off and on the options

Call toolbarson

Application.SetOption "Confirm Action Queries", 1
Application.SetOption "Confirm Document Deletions", 1
Application.SetOption "Confirm Record Changes", 1

End Sub

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
D

DawnTreader

Hello

that is kinda funny. i saw most of your post in another thread.

i have no idea what DAO is. i dont know if i am using it or why i would. all
i know is that i have the code:

Application.SetOption "Confirm Action Queries", 0
Application.SetOption "Confirm Document Deletions", 0
Application.SetOption "Confirm Record Changes", 0

at the opening of my main form, and a few other forms that specifically deal
with action queries. then i have the code:

Application.SetOption "Confirm Action Queries", 1
Application.SetOption "Confirm Document Deletions", 1
Application.SetOption "Confirm Record Changes", 1

at the close of each of those other areas and then at the end of my main form.

if i were to put the code in the "begining" and the "end" of my app and in
all my error code, would that be sufficient?

i know that all you gurus know what the uses and differences are with the
DAO and the ADO and stuff, but for the moment i need to fix the problem, then
when i can i will learn more about DAO and ADO and see if i can be more
effcient. but at the moment i just need one answer, yes or no.

i am very greatful for all the help and suggestions. the problem is i dont
have time to rework anything to make it better, yet...

my boss basically wants me to stop developing this database and do the job i
was originally hired for. so for the time being a "patch" is needed to fix
the imeadiate problem.

please understand, i really really really appreciate your help. :)
 

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