SQL in VB

mohammadagul

PrinceAtif
Local time
Today, 03:45
Joined
Mar 14, 2004
Messages
298
i am trying to write this in a module . Basically the code workds but it also gives me an alert message for the query

Dim strSQL as string
strSQL = "DELETE * FROM tblInvoices"
Docmd.runcommand strsql

when this module is run it gives me an alert of deleting records . if i turn of the Action Queries chekcbox in the options, this does not show. What can be changed in this code to prevent showing he Alert message even ifthe action query check box is checked
 
Either turn off warnings before you use it

docmd.setwarnings false
' runcommand
docmd setwarning true

or try the .execute method of the current datase

currentdb.execute "DELETE * FROM tblInvoices",dbfailonerror
 
how about dao method.. or somthing of recordset
if was thinking of using the DAO..
and pelase tell mehow to use theexecute method in VB
 
Don't use recordsets for deletions! Always execute queries. The above sample is using the execute method of the current database, which is a DAO method.
 

Users who are viewing this thread

Back
Top Bottom