PC Review


Reply
Thread Tools Rate Thread

Disable Access Update Records warning

 
 
kbremner@beeline-online.net
Guest
Posts: n/a
 
      17th Jan 2011
Is there a way to disable the MSAccess Update Records warning box in
certain instances? I have a button that performs an update query on
the record set. It first sets a field in all of the records to a
specific response and then copies the data from another source into
the record set. This will prompt the user twice that they are making
changes. I am afraid this is going to confuse users. I want to either
eliminate these warnings or replace them with my own.
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      17th Jan 2011
On Mon, 17 Jan 2011 07:18:40 -0800 (PST), (E-Mail Removed) wrote:

>Is there a way to disable the MSAccess Update Records warning box in
>certain instances? I have a button that performs an update query on
>the record set. It first sets a field in all of the records to a
>specific response and then copies the data from another source into
>the record set. This will prompt the user twice that they are making
>changes. I am afraid this is going to confuse users. I want to either
>eliminate these warnings or replace them with my own.


There are two ways. One is to use

DoCmd.SetWarnings False

before the line running the query; if you do so you *MUST BE SURE* to put

DoCmd.SetWarnings True

after the query execution line, or you'll turn off all other warning messages
for the rest of the Access session.

Better is to use the Execute method, which allows you to trap and correctly
respond to errors, and doesn't pop up the automatic warning messages:

Dim db As DAO.Database
On Error GoTo Proc_Error
<code preparing for the query to run>
Set db = CurrentDb
db.Execute "YourQueryNameHere", dbFailOnError
<the rest of your code>
Proc_Exit:
Exit Sub
Proc_Error:
If Err.Number = <some specific error>
<handle that error appropriately>
Else
MsgBox "Error " & Err.Number & " in running the update query" _
& vbCrLf & Err.Description
End If
Resume Proc_Exit
End Sub

It looks like a lot of code, but the On Error line and the error handling
block from Proc_Exit to the end (or code like it) should be included in *ALL*
your VBA code.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
David-W-Fenton
Guest
Posts: n/a
 
      17th Jan 2011
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:(E-Mail Removed):

> It looks like a lot of code


If you want a simple replacement for DoCmd.RunQuery without writing
new code, see my SQLRun() function after my signature. It's been in
production use in my apps for several years now, and I use it
instead of writing an error handler each time I need to use .Execute
to run DML SQL.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Public Function SQLRun(strSQL As String, Optional db As Database, _
Optional lngRecordsAffected As Long) As Long
On Error GoTo errHandler
Dim bolCleanup As Boolean

If db Is Nothing Then
Set db = CurrentDb
bolCleanup = True
End If
db.Execute strSQL, dbFailOnError
lngRecordsAffected = db.RecordsAffected

exitRoutine:
If bolCleanup Then
Set db = Nothing
End If
SQLRun = lngRecordsAffected
'Debug.Print strSQL
Exit Function

errHandler:
MsgBox "There was an error executing your SQL string: " _
& vbCrLf & vbCrLf & Err.Number & ": " _
& Err.Description, vbExclamation, "Error in mdlDWF.SQLRun()"
Debug.Print "SQL Error: " & strSQL
Resume exitRoutine
End Function
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable 'Update' Warning Camel Windows XP General 9 6th Feb 2006 08:19 PM
Disable program is trying to access email warning shane-dated-1117606827.91fa97@cm.nu Microsoft Outlook Discussion 3 2nd May 2005 09:18 PM
Any way to Disable Update Warning? (CA Antivirus V7.06.07) 1966olds Anti-Virus 0 21st Feb 2005 01:26 AM
Any way to Disable Update Warning? (CA Antivirus V7.06.07) 1966olds Anti-Virus 0 20th Feb 2005 07:01 PM
how to disable in access Outlook warning JP Microsoft Access Security 2 4th Oct 2003 01:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 PM.