|
-
January 3rd, 2000, 06:39 PM
#1
Foxpro table error
Hi folks, I am trying to create a foxpro table at runtime to which I will add some data at a later point. The table needs to have the same structure as another Access table in teh TableDefs collection.
I have some code like this that is based on an example I found on microsoft.com
private Sub Form_Load()
Dim dbs as Database
Dim tdfNewExternalDatabase as TableDef
Dim tdfTestNewTable as TableDef
Dim fldContactName as Field
Dim fldPhoneNumber as Field
Dim qdfInsertRecords as QueryDef
Dim rstCheckRecordCount as Recordset
Dim intNumRecords as Integer
set dbs = OpenDatabase("C:\FoxPro\Data\db1.mdb", false, false)
set tdfNewExternalDatabase = dbs.CreateTableDef("AccessTable")
set fldContactName = tdfNewExternalDatabase.CreateField("Contact_Name", dbText)
fldContactName.Size = 30
set fldPhoneNumber = tdfNewExternalDatabase.CreateField("Phone_Number", dbText)
fldPhoneNumber.Size = 25
tdfNewExternalDatabase.Fields.Append fldContactName
tdfNewExternalDatabase.Fields.Append fldPhoneNumber
dbs.TableDefs.Append tdfNewExternalDatabase
DoCmd.TransferDatabase acExport, "dBase IV", "C:\FoxPro\Data", acTable, _
"AccessTable", "FoxTable"
dbs.TableDefs.Delete "AccessTable"
set tdfTestNewTable = dbs.CreateTableDef("FoxTable")
tdfTestNewTable.Connect = "dBase IV;DATABASE=C:\FoxPro\Data;"
tdfTestNewTable.SourceTableName = "FoxTable"
dbs.TableDefs.Append tdfTestNewTable
End Sub
The line of code
tdfTestNewTable.SourceTableName = "FoxTable"
dbs.TableDefs.Append tdfTestNewTable
gives me the error that the object FoxTable can't be found. According to the example code, everything is right.
Any ideas?
Thanks
Andrew
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|