suppress warnings on DoCmd.RunSQL ? 
Author Message
 suppress warnings on DoCmd.RunSQL ?

I am executing an insert using DoCmd.RunSQL ("mySQLstring") in a module. How
can I suppress the "You are about to append 1 rows" message as I am gonna
use this to insert a bunch of records. Thanks
Terry


Sun, 21 Nov 2004 03:42:33 GMT  
 suppress warnings on DoCmd.RunSQL ?
There are two ways.
1) Go to Tools>Options>Edit/Find and click off the check
boxes for Confirm.

2) If you are distributing the application to many users
the following code turns off and on the action queries
when the form is Open or Closed.  The first 3 lines should
appear at the top of the form module.

Option Compare Database
Option Explicit
Public change As Boolean
Private Sub Form_Close()
    'Turn messages back on
    If change = False Then
    Application.SetOption "Confirm Action Queries", True
    End If
End Sub

Private Sub Form_Open(Cancel As Integer)
    Dim x
    'Confirm record changes is on turn messages off
    x = Application.GetOption("Confirm Action Queries")
    If x = True Then
    Application.SetOption "Confirm Action Queries", False
    change = False
    End If
End Sub

Quote:
>-----Original Message-----
>I am executing an insert using DoCmd.RunSQL

("mySQLstring") in a module. How
Quote:
>can I suppress the "You are about to append 1 rows"

message as I am gonna
Quote:
>use this to insert a bunch of records. Thanks
>Terry

>.



Sun, 21 Nov 2004 04:25:27 GMT  
 suppress warnings on DoCmd.RunSQL ?


Quote:
>I am executing an insert using DoCmd.RunSQL ("mySQLstring") in a module. How
>can I suppress the "You are about to append 1 rows" message as I am gonna
>use this to insert a bunch of records. Thanks
>Terry

A couple of answers:

1.

DoCmd.SetWarnings False
DoCmd.RunSQL("MySQLString")
DoCmd.SetWarnings True

2. (better, in that errors are easier to trap; worse in that it's a
bit more code):

Dim db As DAO.Database
Dim qd As DAO.Querydef
Set db = CurrentDb
Set qd = db.CreateQuerydef("", "MySQLString")
On Error GoTo Proc_Error
qd.Execute dbFailOnError
<...>
Proc_Error:
 <error trapping code>

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Sun, 21 Nov 2004 04:40:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. suppressing of docmd.runsql dialogbox

2. DoCmd.RunSQL

3. DoCmd.RunSQL Error

4. DoCmd.RunSQL error 2

5. docmd.RunSql problem

6. docmd.RunSQL String Concatenation

7. DoCmd.RunSQL too long record

8. DoCmd.RunSQL

9. docmd.runsql repeat problem

10. docmd.runsql help required

11. DoCmd.RunSQL vs. Recordsets

12. docmd.runSQL fails on Windows 2000

 

 
Powered by phpBB® Forum Software