Click to See Complete Forum and Search --> : Please Help Me!
Melvana
Oct 3rd, 2000, 02:27 PM
How can I delete all the records of 9 tables?
All 9 tables are in the same .mdb database.
I dont't know if I have to use one ADO(or DAO) for each
table or maybe there is a better way to do that...
I don't know.
All I know is that my SQL should look like this:
"delete from TableName;"
Anybody please help me
jdavison
Oct 3rd, 2000, 04:01 PM
I havent tried this yet but I think you can just use the * wildcard in the sql.
DELETE * FROM *
if it doesnt work then you will need to take the * of the FROM and do individual tables but I think that should work for you.
Melvana
Oct 4th, 2000, 03:13 PM
I tryed that but it doesn't work :( (SQL error)
Thank anyway :)
Anyone can help me?
try this:
' this code was taken from 101 Tech Tips by VBPJ
Function ZapTable(sTable as STring, Optional sWhere as String = "") as Integer
Dim sSQL as String
On Error GoTo Err_ZapRecs
' For Access Apps only:
' docmd.SetWarnings False
sSQL = "DELETE * FROM " & sTable & " "
If sWhere <> "" Then
sSQL = sSQL & "WHERE " & sWhere
End If
DB.Execute sSQL, dbFailOnError
' docmd.SetWarnings True
ZapTable = True
Exit_ZapRecs:
Exit Function
Err_ZapRecs:
ZapTable = False
''ERROR HANDLING IF DESIRED
Resume Exit_ZapRecs
End Function
hope this helps. :)
Melvana
Oct 4th, 2000, 03:46 PM
What type is DB in your function?
whatever database object you have.
Melvana
Oct 4th, 2000, 04:44 PM
Hooooooooooooo yeah :)
thank you billyboy, your help was just what I needed.
It works perfectly, like I want.
thank you again :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.