RunSQL question 
Author Message
 RunSQL question

Hello,
I have this statement in my code and it prompts me a
dialog box that says delete will be performed. Is there a
way to perform this in a silent mode.

   ' set date
   trancateDate = Date - maxLogDay

   ' SQL delete string
   sqlString = " DELETE * " & _
               " FROM " & errorLogTableName & _
               " WHERE Date <#" & trancateDate & "#;"

   DoCmd.RunSQL (sqlString)

Or is there any other way to delete some records in a
table?

Thanks,
Jim.



Sat, 12 Nov 2005 22:20:03 GMT  
 RunSQL question
Quote:

> Hello,
> I have this statement in my code and it prompts me a
> dialog box that says delete will be performed. Is there a
> way to perform this in a silent mode.

>    ' set date
>    trancateDate = Date - maxLogDay

>    ' SQL delete string
>    sqlString = " DELETE * " & _
>                " FROM " & errorLogTableName & _
>                " WHERE Date <#" & trancateDate & "#;"

>    DoCmd.RunSQL (sqlString)

> Or is there any other way to delete some records in a
> table?

> Thanks,
> Jim.

either:

DoCmd.SetWarnings False
Docmd.RunSQL sqlString
DoCmd.SetWarnings True

or

Dim db As DAO.Database
Set db = CurrentDb
db.Execute strSQL
Set db = Nothing

--

Tony Oakley (Microsoft Access MVP)
GSXR1300R Hayabusa
300hr 240GB TiVo



Sat, 12 Nov 2005 22:39:41 GMT  
 RunSQL question

Quote:

> > Hello,
> > I have this statement in my code and it prompts me a
> > dialog box that says delete will be performed. Is there a
> > way to perform this in a silent mode.

> >    ' set date
> >    trancateDate = Date - maxLogDay

> >    ' SQL delete string
> >    sqlString = " DELETE * " & _
> >                " FROM " & errorLogTableName & _
> >                " WHERE Date <#" & trancateDate & "#;"

> >    DoCmd.RunSQL (sqlString)

> > Or is there any other way to delete some records in a
> > table?

> Dim db As DAO.Database
> Set db = CurrentDb
> db.Execute strSQL
> Set db = Nothing

Just to tag onto Tony's answer, you might want to use

db.Execute strSQL, dbFailOnError

That lets you determine whether or not the SQL succeeded (it'll raise an
error that you can trap the way you trap any other error)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele



Sat, 12 Nov 2005 22:43:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Quick syntax question on - DoCmd.RunSQL

2. DoCmd.RunSQL "Insert Into...Values....;" question

3. DoCmd.RunSQL

4. DoCmd.RunSQL Error

5. DoCmd.RunSQL error 2

6. docmd.RunSql problem

7. docmd.RunSQL String Concatenation

8. DoCmd.RunSQL too long record

9. DoCmd.RunSQL

10. More RunSQL issues

11. RunSQL method

12. VBA - RunSQL Command

 

 
Powered by phpBB® Forum Software