Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Access97

Status
Not open for further replies.

PerryG

Programmer
Aug 15, 2000
75
US
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.
 
The problem is with this line:
For intI = 1 To intFldCount
It needs to be
For intI = 0 To intFldCount - 1

DAO collections are accessed with indexes from 0 to .Count - 1.


Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Yeah, I just caught that....how embarassing. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top