Hello all
I've searched through a lot of previous strings for this topic and I can't find what i'm looking for so i'm hoping someone can help me. I am simply trying to create a new Access table through DAO in VB. When I try to append my newly defined table I get an "Invalid Argument" error. I just can't see what im doing wrong! Can anyone point me in the right direction?
The database object i pass this function is an open access database. The table was opened using
Thanks
Erin
I've searched through a lot of previous strings for this topic and I can't find what i'm looking for so i'm hoping someone can help me. I am simply trying to create a new Access table through DAO in VB. When I try to append my newly defined table I get an "Invalid Argument" error. I just can't see what im doing wrong! Can anyone point me in the right direction?
Code:
Public Function teplCheck(D As Database)
Dim Td As New TableDef, fld() As New Field
Dim Idx() As New index, I As Integer
ReDim fld(1 To 3), Idx(1 To 2)
Td.name = "Tepl1" ' Set the table name.
' Create Fields.
fld(1).Attributes = DB_AUTOINCRFIELD ' Counter field.
For I = 1 To 3 ' Set properties for fields.
fld(I).name = Choose(I, "Name", "Description", "Default")
fld(I).Type = Choose(I, DB_TEXT, DB_TEXT, DB_INTEGER)
fld(I).Size = Choose(I, 50, 200, 5)
Td.Fields.Append fld(I)
Next I
' Create Indexes.
Idx(1).name = "@0"
Idx(1).Fields = "Default"
Idx(2).name = "@1"
Idx(2).Fields = "Name"
For I = 1 To 2
Td.Indexes.Append Idx(I)
Next I
' Create Table.
D.TableDefs.Append Td
End Function
The database object i pass this function is an open access database. The table was opened using
Code:
Set sysdb = OpenDatabase(projectPath & "SystemDB.mdb", False, False)
Thanks
Erin