How to empty a table with VB 
Author Message
 How to empty a table with VB

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



Tue, 04 Jan 2005 00:32:01 GMT  
 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



Tue, 04 Jan 2005 00:39:09 GMT  
 How to empty a table with VB
DELETE FROM Books

--
Patrick Logan, MCSD
Opinions expressed are my own and not necessarily those of my employer.


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



Tue, 04 Jan 2005 01:34:04 GMT  
 How to empty a table with VB
Issue a SQL statement of :

DELETE FROM MyTable

HTH
--
Patrick Logan, MCSD
Opinions expressed are my own and not necessarily those of my employer.


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



Tue, 04 Jan 2005 01:33:36 GMT  
 How to empty a table with VB
dbPath = <path>
Set dbMyDatabase = DBEngine.Workspaces(0).OpenDatabas _
(dbPath)
dbMyDatabase.Execute "Delete * from books"

Quote:
>-----Original Message-----
>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
Quote:
>to erase all the data in the table but still keep the

structure. Can anyone
Quote:
>give me a hint, code or even a web site to help?
>Your help is always greatly appreciated,

>James

>.



Tue, 04 Jan 2005 06:17:55 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Empty resultset when adding to empty table : error

2. Empty tables in a multi-tables query

3. Empty tables in a multi-tables query

4. linked table empty

5. filling in empty table

6. Problem with Empty or Null fields in a Table on a Report

7. Append Query on empty table

8. Empty Tables and Errors

9. create empty table from query

10. Checking for empty table

11. Updating empty strings in a table

12. Creating a new database and adding appropriate empty tables

 

 
Powered by phpBB® Forum Software