I'm having trouble with a TableDef....keeps throwing a runtime error 3265 when I try to add it to the collection.
I'm recreating a table substituting more meaningful field names for the convenience of the QA group. Here's the failing code:
Set db = CurrentDb
Set rst = db.OpenRecordset("pem0102_test", dbOpenDynaset)
Set rst2 = db.OpenRecordset("parameter list", dbOpenDynaset)
Set tdf = db.CreateTableDef("pem0102_test_2"
intFldCount = rst.Fields.Count
With rst
For intI = 1 To intFldCount
strFName = rst.Fields(intI).Name
strCriteria = "[Parameter] = " & "'" & strFName & "'"
With rst2
.FindFirst strCriteria
If .NoMatch Then
strNewName = strFName
Else
strNewName = !Description.Value
End If
End With
With tdf
.Fields.Append .CreateField(strNewName, dbText, 255)
.Fields.Refresh
End With
Next
db.TableDefs.Append tdf
db.TableDefs.Refresh
End With
Any help appreciated.
I'm recreating a table substituting more meaningful field names for the convenience of the QA group. Here's the failing code:
Set db = CurrentDb
Set rst = db.OpenRecordset("pem0102_test", dbOpenDynaset)
Set rst2 = db.OpenRecordset("parameter list", dbOpenDynaset)
Set tdf = db.CreateTableDef("pem0102_test_2"
intFldCount = rst.Fields.Count
With rst
For intI = 1 To intFldCount
strFName = rst.Fields(intI).Name
strCriteria = "[Parameter] = " & "'" & strFName & "'"
With rst2
.FindFirst strCriteria
If .NoMatch Then
strNewName = strFName
Else
strNewName = !Description.Value
End If
End With
With tdf
.Fields.Append .CreateField(strNewName, dbText, 255)
.Fields.Refresh
End With
Next
db.TableDefs.Append tdf
db.TableDefs.Refresh
End With
Any help appreciated.