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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foxpro 2.6 & VB 6 - Accessing files

Status
Not open for further replies.

nitemarepc

Programmer
Jan 11, 2001
5
US
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:
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(&quot;C:\OnlineFiles\tempdest.mdb&quot;) <> &quot;&quot; Then Kill &quot;C:\OnlineFiles\tempdest.mdb&quot;
Set dbtempdest = DBEngine.Workspaces(0).CreateDatabase(&quot;C:\OnlineFiles\tempdest.mdb&quot;, dbLangGeneral)
Set tdtempdest = dbtempdest.CreateTableDef(&quot;tempdest&quot;)
With tdtempdest
    .Fields.Append .CreateField(&quot;cPub&quot;, dbText, 3)
    .Fields.Append .CreateField(&quot;cReorg&quot;, dbText, 4)
    .Fields.Append .CreateField(&quot;cPull&quot;, dbText, 4)
    .Fields.Append .CreateField(&quot;cSeq&quot;, dbText, 3)
    .Fields.Append .CreateField(&quot;cItemCode&quot;, dbText, 15)
End With
dbtempdest.TableDefs.Append tdtempdest
With tdtempdest
    Set idxPRPS = .CreateIndex(&quot;PRPS&quot;)
    With idxPRPS
        .Fields.Append .CreateField(&quot;cPub&quot;)
        .Fields.Append .CreateField(&quot;cReorg&quot;)
        .Fields.Append .CreateField(&quot;cPull&quot;)
        .Fields.Append .CreateField(&quot;cSeq&quot;)
    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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top