C
Craig
Having issues with this. Get an datatype conversion error on the
'createfield' line. Doesn't seem to like the rs("Type") or rs("Size").
However, these values are being pulled from another table (Damages) and are
legitimate values (ie, dbText, etc.).
Also, is there a better way to create a table (maybe SQL syntax)?? Thanks
for any help.
Sub Createtable()
Dim tdfNew As TableDef
Dim db As Database
Dim rs As Recordset
Dim intCount As Integer
Set db = CurrentDb()
' Create a new TableDef object.
Set tdfNew = db.CreateTableDef("tblDamage")
Set rs = db.OpenRecordset("Damages")
intCount = rs.RecordCount
rs.MoveFirst
'
With tdfNew
For i = 1 To intCount
.Fields.Append .CreateField(rs("Name"), rs("Type"), rs("Size"))
rs.MoveNext
Next i
' Append the new TableDef object
db.TableDefs.Append tdfNew
End With
'
rs.Close
Set db = Nothing
'
End Sub
'createfield' line. Doesn't seem to like the rs("Type") or rs("Size").
However, these values are being pulled from another table (Damages) and are
legitimate values (ie, dbText, etc.).
Also, is there a better way to create a table (maybe SQL syntax)?? Thanks
for any help.
Sub Createtable()
Dim tdfNew As TableDef
Dim db As Database
Dim rs As Recordset
Dim intCount As Integer
Set db = CurrentDb()
' Create a new TableDef object.
Set tdfNew = db.CreateTableDef("tblDamage")
Set rs = db.OpenRecordset("Damages")
intCount = rs.RecordCount
rs.MoveFirst
'
With tdfNew
For i = 1 To intCount
.Fields.Append .CreateField(rs("Name"), rs("Type"), rs("Size"))
rs.MoveNext
Next i
' Append the new TableDef object
db.TableDefs.Append tdfNew
End With
'
rs.Close
Set db = Nothing
'
End Sub