Adding a new table in Access Database from VB3 
Author Message
 Adding a new table in Access Database from VB3

hi all,

How to add a new table to a database ?
- I can create a new database
- I can add a new field to an existing database
- I can't create a new table in a database ?????????

I've got always the same message, "Unknown name in the collection"
- did i forgot declare a variable ?
- The syntax of the last line is ok ?

Can some one give me the right code to resolve this problem.

thanks to all
J.C
.

Quote:
>Set BaseDeDatos = CreateDatabase("DataBase.mdb",

DB_LANG_GENERAL, >DB_VERSION10)
Quote:
>Set BaseDeDatos = OpenDatabase("Database", False, False)
>Dim NewTable As New TableDef
>NewTable.Name = "MyTable"
>Dim NewField As New Field
>Const DB_TEXT = 10                   ' Set field type constant.
>NewField.Name = "MyField"     ' Set field properties.
>NewField.Type = DB_TEXT
>NewField.Size = 12
>BaseDeDatos.TableDefs(NewTable).Fields.Append NewField



Thu, 26 Jun 2003 08:36:15 GMT  
 Adding a new table in Access Database from VB3



Quote:
> hi all,

> How to add a new table to a database ?
> - I can create a new database
> - I can add a new field to an existing database
> - I can't create a new table in a database ?????????

You create a TableDef, append your fields and indexes (if any) to it.  I
don't have VB3 on this PC but I believe the method is AddTableDef the
example code there shows how to define fields and add them to the table
definition.

Hope this helps.  Sorry I don't have any examples to post, but like I said
VB3 isn't on this machine.

Best,
Bill

Quote:

> I've got always the same message, "Unknown name in the collection"
> - did i forgot declare a variable ?
> - The syntax of the last line is ok ?

> Can some one give me the right code to resolve this problem.

> thanks to all
> J.C
> .
> >Set BaseDeDatos = CreateDatabase("DataBase.mdb",
> DB_LANG_GENERAL, >DB_VERSION10)

> >Set BaseDeDatos = OpenDatabase("Database", False, False)

> >Dim NewTable As New TableDef

> >NewTable.Name = "MyTable"

> >Dim NewField As New Field
> >Const DB_TEXT = 10                   ' Set field type constant.
> >NewField.Name = "MyField"     ' Set field properties.
> >NewField.Type = DB_TEXT
> >NewField.Size = 12

> >BaseDeDatos.TableDefs(NewTable).Fields.Append NewField



Sat, 28 Jun 2003 02:39:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to modified existing field and add new field in existing table for Access database

2. Creating a new database and adding appropriate empty tables

3. Need to add new tables to a database

4. word VBA won't let me add a new record to an access table

5. Crystal Report cannot see new field that is added to MS Access table

6. I need to be able to add new fields to a MS Access table via VbScript

7. I need to be able to add new fields to a MS Access table via VbScript

8. Copying the structure of one Access table to a new Access table

9. Weird ASP error when trying to add a new record to a MS Access database

10. Can't add new record to Access database with DataControl

11. add new record to MS ACCESS database

12. Can't add new record to Access database with data control

 

 
Powered by phpBB® Forum Software