DELETING TABLE, CREATING NEW TABLE 
Author Message
 DELETING TABLE, CREATING NEW TABLE

Greetings everyone,

I am trying to delete an old table and replace it with a new one
(through code) in MS-Access. For deleting the table I am able to use the
DeleteObject action in a macro. But in order to replace it with a new
table, I try to use Mydatabase.OpenRecordset("NewTableName"). The help
files suggest that OpenRecordset will create a new table, but there is
an error message at run time that NewTableName does not exist. How to
create a new table??

Thanks in advance,
Ashant...

--
Ashant Chalasani                        

http://www.*-*-*.com/ ~ashant/
Ph:765-495-8236



Wed, 21 Jun 2000 03:00:00 GMT  
 DELETING TABLE, CREATING NEW TABLE

The easiest way I can think of is as follows.

 On Error Resume Next
    Set tdfnew = dbsexist.CreateTableDef("NewTable")       'Of course if we
get an error, it's already there
    If Error <> "" Then
' If we don't lets build it
    With tdfnew
        .Fields.Append .CreateField("UserID", dbText)
        .Fields.Append .CreateField("Date", dbText)
        .Fields.Append .CreateField("Time", dbMemo)
    End With
    dbsexist.TableDefs.Append tdfnew                                 'Make
the new table part of things
    Else
    End If
    Set rstProgramEntry = dbsNew.OpenRecordset("NewTable")      'It was
already here, so we do this...
    rstProgramEntry.MoveLast
    rstProgramEntry.MoveFirst
    rstProgramEntry.Edit

Hope this helps..


Quote:

>Greetings everyone,

>I am trying to delete an old table and replace it with a new one
>(through code) in MS-Access. For deleting the table I am able to use the
>DeleteObject action in a macro. But in order to replace it with a new
>table, I try to use Mydatabase.OpenRecordset("NewTableName"). The help
>files suggest that OpenRecordset will create a new table, but there is
>an error message at run time that NewTableName does not exist. How to
>create a new table??

>Thanks in advance,
>Ashant...

>--
>Ashant Chalasani

>http://expert.cc.purdue.edu/~ashant/
>Ph:765-495-8236



Wed, 21 Jun 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. create table and delete table with ADO

2. Create new fields in a table based off of fields in another table

3. Create new field in existing table exactly like field in second table

4. Copying table definition to create new table

5. DELETED tables cause error on table Connect?

6. deleting tables and updating table name

7. Retaining styles in table cells when deleting table

8. Cannot add record to Visual Foxpro table after deleting all records in table

9. deleting records in a table and then adding new records

10. Copying the structure of a table to a new table

11. Using DAO 3.5 to Make a New Table from an Exisiting Table

12. need help please:joined tables,add new entries based on one table columns

 

 
Powered by phpBB® Forum Software