-
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
-
I havent tried this yet but I think you can just use the * wildcard in the sql.
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.
-
I tryed that but it doesn't work :( (SQL error)
Thank anyway :)
Anyone can help me?
-
try this:
Code:
' 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. :)
-
What type is DB in your function?
-
whatever database object you have.
-
Hooooooooooooo yeah :)
thank you billyboy, your help was just what I needed.
It works perfectly, like I want.
thank you again :)