
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