nitemarepc
Programmer
I have tried to access the Foxpro 2.6 files with Visual Basic 6 using SQL with no luck. This is the code and according to everything I have read and the help with Visual Basic, it should work. I get an error of invalid argument for the append (dbtempdest.TableDefs.Append tdtempdest1). I need to figure this out!!! Can anyone help me??
Here is the code:
Here is the code:
Code:
Public Function Destroy()
Dim dbtempdest As Database
Dim tdtempdest1 As TableDef
Dim tdtempdest2 As TableDef
Dim idxPRPS As Index
Dim strTable1 As String
Dim strTable2 As String
Dim strConnect As String
Dim strSrcTabl1 As String
Dim strSrcTabl2 As String
Dim strSQL As String
strTable1="Component"
strTable2="Mastercomp"
strConnect="FoxPro 2.6;DATABASE =c:\systems\wiltonline\dbfs"
strSrcTabl1="compnent"
strSrcTabl2="mastrcmp"
strSQL = "INSERT INTO tdtempdest " & _
"SELECT DISTINCT tdtempdest1!cPub, tdtempdest1!cReorg, " & _
"tdtempdest1!cPull, tdtempdest1!cSeq, tdtempdest1!cItemCode " & _
"FROM [tdtempdest1] INNER JOIN [tdtempdest2] " & _
"ON tdtempdest1!cItemCode = tdtempdest2!cItemCode " & _
"WHERE tdtempdest1!lInactive = False " & _
"AND tdtempdest2!cDestroy = 'Y' " & _
"OR tdtempdest2!cRecStatus = 'D' " & _
"OR tdtempdest2!cRecStatus = 'K' " & _
"ORDER BY tdtempdest1!cPub, tdtempdest1!cReorg, tdtempdest1!cPull, tdtempdest1!cSeq"
If Dir("C:\OnlineFiles\tempdest.mdb") <> "" Then Kill "C:\OnlineFiles\tempdest.mdb"
Set dbtempdest = DBEngine.Workspaces(0).CreateDatabase("C:\OnlineFiles\tempdest.mdb", dbLangGeneral)
Set tdtempdest = dbtempdest.CreateTableDef("tempdest")
With tdtempdest
.Fields.Append .CreateField("cPub", dbText, 3)
.Fields.Append .CreateField("cReorg", dbText, 4)
.Fields.Append .CreateField("cPull", dbText, 4)
.Fields.Append .CreateField("cSeq", dbText, 3)
.Fields.Append .CreateField("cItemCode", dbText, 15)
End With
dbtempdest.TableDefs.Append tdtempdest
With tdtempdest
Set idxPRPS = .CreateIndex("PRPS")
With idxPRPS
.Fields.Append .CreateField("cPub")
.Fields.Append .CreateField("cReorg")
.Fields.Append .CreateField("cPull")
.Fields.Append .CreateField("cSeq")
End With
.Indexes.Append idxPRPS
.Indexes.Refresh
End With
Set tdtempdest1 = dbtempdest.CreateTableDef(strTable1)
tdtempdest1.Connect = strConnect
tdtempdest1.SourceTableName = strSrcTabl1
Set tdtempdest2 = dbtempdest.CreateTableDef(strTable2)
tdtempdest2.Connect = strConnect
tdtempdest2.SourceTableName = strSrcTabl2
dbtempdest.TableDefs.Append tdtempdest1
dbtempdest.TableDefs.Append tdtempdest2
dbtempdest.Execute strSQL
End Function