
How to empty a table with VB
You can give this a try (its DAO but simple)
Carter
Function CleanTable(tblName As String) As Boolean
On Error GoTo CleanTable_Err
Dim dbs As Database
Dim rst As Recordset
Dim check As Boolean
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(tblName)
Do While Not rst.EOF
rst.Delete
rst.MoveNext
Loop
check = True
CleanTable_Exit:
Set rst = Nothing
Set dbs = Nothing
CleanTable = check
Exit Function
CleanTable_Err:
MsgBox "Error! " & Err.Description
check = False
GoTo CleanTable_Exit
End Function
Quote:
> Hi everyone, I have a A2K db wit a table called books. I already work VB
> code to export in a text file, but since this is a temporary table I would
> to erase all the data in the table but still keep the structure. Can
anyone
> give me a hint, code or even a web site to help?
> Your help is always greatly appreciated,
> James