PDA

View Full Version : Solved: Delete Action Query problem



beginner
09-19-2005, 10:56 AM
hi all helpers,

got a problem on Delete all records in a table ABC, coding as below, appreciate any adv....tks a lot. :hi:

Dim myDB As DAO.Database
Dim myTable As String
Dim mySql As String

myTable ="ABC"

Set myDB = CurrentDb
'mySql = "DELETE * FROM " & myTable ' have tried this but not work

mySql = "DELETE " & myTable & ".* FROM " & myTable

myDB.Execute (mySql)

beginner

Norie
09-19-2005, 12:19 PM
What's the actual problem?

xCav8r
09-19-2005, 07:06 PM
hey, beginner :hi:

I don't see a problem here either. What line is generating the error and what's the error?

Also, have you tried...

docmd.runsql MySql

That doesn't required DAO.

xCav8r
09-20-2005, 03:18 PM
I split this into two threads when you asked your new question, but I didn't know how to split your post up, so I'm putting it here myself. ;)


hello Norie and xCav8r,

finally i found the problem is due to my table name's format xxx-xxxx-xxx which give out the error (saying ...syntax wrong in the From sentence...etc.) and can solved finally by enclosed bracket [ ] as below. tks for adv.

Set myDB = CurrentDb
myTable ="[xxx-xxxx-xxx]"
mySql = "DELETE " & myTable & ".* FROM " & myTable
myDB.Execute (mySql)

beginner
09-23-2005, 10:34 PM
hi xCav8r,

thanks for your help for splitting but i didn't see my new question thread in the thread list, or do you mean i need to re-post my new question again ?

Tks
beginner

beginner
09-24-2005, 03:53 AM
hi xCav8r......i found that thread already, thanks a lot!