read/write FoxPro 2.6 *and* Access 97 database files 
Author Message
 read/write FoxPro 2.6 *and* Access 97 database files

I need to read/write FoxPro 2.6 *and* Access 97 database files for an
application I'm working on.  Will VB (version?) provide the necessary
capability?  Is there any other development tool that might be a better
fit?

Thanks,

Mark



Mon, 26 Feb 2001 03:00:00 GMT  
 read/write FoxPro 2.6 *and* Access 97 database files
Yes Mark

Here is a real example that I am using on a current program with VB5

       sInvFile = sPath & "ARINV02"
       sTrsFile = sPath & "ARTRS02"

       Set dbsARINV = OpenDatabase(sPath, False, False, "Foxpro 2.6;")
       Set rstARINV = dbsARINV.OpenRecordset("ARINV02")

       Set dbsARTRS = OpenDatabase(sPath, False, False, "Foxpro 2.6;")
       Set rstARTRS = dbsARTRS.OpenRecordset("ARTRS02")

Hope it helps...
Bill

On Thu, 10 Sep 1998 15:06:21 -0400, Mark Scott Smith

Quote:

>I need to read/write FoxPro 2.6 *and* Access 97 database files for an
>application I'm working on.  Will VB (version?) provide the necessary
>capability?  Is there any other development tool that might be a better
>fit?

>Thanks,

>Mark



Mon, 26 Feb 2001 03:00:00 GMT  
 read/write FoxPro 2.6 *and* Access 97 database files
Mark,

I kind of left a bunch of detail out.    Maybe the whole SUB will make
more sense...

Note:    Using Access 97 is no problem because it is a native in
VB5/VB6.       There is a section in the online help that covers
"External Databases" that tells how to use .dbf and other structures.

EXAMPLE:        ( not necessarily the cleanest code :-) )

Sub SumBalance(sMonthDay)
    Dim curNTaxAmt As Currency
    Dim curAmount As Currency
    Dim curSumINV As Currency
    Dim curSumTRS As Currency
    Dim sZipFile As String
    Dim sInvFile As String
    Dim sTrsFile As String
    Dim CRLF As String
    Dim iDummy As Integer
    Dim iCtr As Integer
    Dim lNumCopied As Long

    Screen.MousePointer = vbHourglass

    frmMain.Hide
    frmProgress.Show
    frmProgress.Refresh       'double call forces complete display
    frmProgress.Refresh

    CRLF = Chr(13) & Chr(10)    'used as line separators in msgbox

    sZipFile = sTemp & "AR02" & sMonthDay
    sInvFile = sPath & "ARINV02"
    sTrsFile = sPath & "ARTRS02"

      'This sets the path to the data files...
    Set dbsARINV = OpenDatabase(sPath, False, False, "Foxpro 2.6;")
      'This creates the recordset for the dbf file...
    Set rstARINV = dbsARINV.OpenRecordset("ARINV02")

      'My second file that is to be used...do like first in setting up
    Set dbsARTRS = OpenDatabase(sPath, False, False, "Foxpro 2.6;")
    Set rstARTRS = dbsARTRS.OpenRecordset("ARTRS02")

    'sum the appropriate fields in the ARINV and ARTRS databases
    With rstARINV
        .MoveFirst
        iCtr = 0
        frmProgress.pbar.Min = 0        'this all sets up min/max for
progress bars...
        If .RecordCount < 14 Then   'so bar fills to end
            frmProgress.pbar.Max = 14
        Else
            frmProgress.pbar.Max = .RecordCount
        End If
        While (Not .EOF)        'now stroll through dbf file on
desired field...
            curSumINV = curSumINV + .Fields("FNTAXAMT")
            iCtr = iCtr + 1
            frmProgress.pbar.Value = iCtr
            .MoveNext
        Wend
    End With

    frmProgress.pbar.Value = 0

    With rstARTRS
        .MoveFirst
        iCtr = 0
        frmProgress.pbar.Min = 0
        If .RecordCount < 14 Then   'so bar fills to end
            frmProgress.pbar.Max = 14
        Else
            frmProgress.pbar.Max = .RecordCount
        End If
        While (Not .EOF)
            curSumTRS = curSumTRS + .Fields("FAMOUNT")
            iCtr = iCtr + 1
            frmProgress.pbar.Value = iCtr
            .MoveNext
        Wend
        If .RecordCount < 14 Then frmProgress.pbar.Value = 14
    End With

    frmProgress.Hide

    Screen.MousePointer = vbDefault

    If curSumINV <> curSumTRS Then
        MsgBox "ERROR in Balances!  ARINV02 = " & Format(curSumINV,
"$###,###.00") & _
                "  :   ARTRS02 = " & Format(curSumTRS, "$###,###.00"),
vbCritical, _
                GetBranchName()
    Else
        MsgBox "Balanced:  ARINV02 = " & Format(curSumINV,
"$###,###.00") & _
                "  :   ARTRS02 = " & Format(curSumTRS, "$###,###.00")
& CRLF & CRLF & _
                "Record this balance." & CRLF, vbInformation, _
                GetBranchName()

        frmProgress.Show
        frmProgress.Refresh       'double call forces complete display
        frmProgress.Refresh

        Screen.MousePointer = vbHourglass

        'copy files to the temp directory
        lNumCopied = rgbCopyFiles(sPath, sTemp, sFiles)

        If lNumCopied > 0 Then
            'use winzip to create a .zip file for transfer
            MakeZipFile sZipFile
        End If

        frmProgress.Hide
        Screen.MousePointer = vbDefault

    End If

    frmMain.Show

    Set rstARINV = Nothing
    Set rstARTRS = Nothing
    Set dbsARINV = Nothing
    Set dbsARTRS = Nothing
End Sub

On Thu, 10 Sep 1998 15:06:21 -0400, Mark Scott Smith

Quote:

>I need to read/write FoxPro 2.6 *and* Access 97 database files for an
>application I'm working on.  Will VB (version?) provide the necessary
>capability?  Is there any other development tool that might be a better
>fit?

>Thanks,

>Mark



Tue, 27 Feb 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Opening a Foxpro 2.6 database using VB 6.0

2. How to create a FoxPro 2.6 database programatically

3. DAO 3.6, Jet 4, Foxpro 2.6 Database problems

4. Problem with a FoxPro 2.6 Database

5. Access 97 and ado 2.6

6. How do I access a foxpro db 2.6?

7. Accessing Foxpro 2.6 DBF from VB with indices

8. Problem encounter when accessing Foxpro 2.6 DB

9. VB5 to access Foxpro 2.6 data

10. Best way to access FoxPro 2.6 tables

11. Using visual FoxPro 2.6 files with VB 3.0

12. Help Required : Reading Comma delimited files and writing to Access Database

 

 
Powered by phpBB® Forum Software