jtseltmann
Programmer
Can anyone see a problem with the following code? I have a function set up to create a table and defs from the header row of an ascii file. I have referenced MS DAO 3.6 Objects library and am running MS Access 2000. Any help would be greatly appreciated. I got the code tips from posts on this site...
'----------------------------------------------
Public Sub CreateTableAndDict(fields As Variant)
Const cRoutine = "CreateTableAndDict"
On Error GoTo ErrorHandler
'---
'Sub creates the temp_999 table/dictionary
'---
Dim db As database
Dim x As Integer
Dim thisfield As Field
Dim newtable As TableDef
Set db = CurrentDb()
Set newtable = db.CreateTableDef()
newtable.Name = "temp_999"
For x = LBound(fields) To UBound(fields)
Set thisfield = newtable.CreateField(fields(x), dbText, 15)
newtable.fields.Append thisfield
Next x
db.TableDefs.Append newtable
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.description, vbExclamation, "Routine - " & cRoutine
Err.Clear
End Sub
'----------------------------------------------
Public Sub CreateTableAndDict(fields As Variant)
Const cRoutine = "CreateTableAndDict"
On Error GoTo ErrorHandler
'---
'Sub creates the temp_999 table/dictionary
'---
Dim db As database
Dim x As Integer
Dim thisfield As Field
Dim newtable As TableDef
Set db = CurrentDb()
Set newtable = db.CreateTableDef()
newtable.Name = "temp_999"
For x = LBound(fields) To UBound(fields)
Set thisfield = newtable.CreateField(fields(x), dbText, 15)
newtable.fields.Append thisfield
Next x
db.TableDefs.Append newtable
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.description, vbExclamation, "Routine - " & cRoutine
Err.Clear
End Sub