Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005

    Unanswered: Access FoxPro 7 DB in VBA...

    Hi folks:
    I am trying to connect to a free table created in FoxPro 7. To do this, I believe I will need to use the OLE driver since the ODBC FoxPro driver won't work with Office 2003. To this end, I've added references for the OLE FoxPro7 driver and the ADODB library. It seems to work up to calling "open" on the record set. This will either a) crash word if I've placed a breakpoint before the line and then proceed into it, or b) just throw an error.

    Here is my code:
    Dim conn

    Public Sub main()
    End Sub

    Private Sub connectToDataSource()

    Const adOpenStatic = 3

    Dim conStr As String
    Dim sqlStr As String
    Dim recSet As ADODB.Recordset

    conStr = "Provider=Microsoft OLE DB Provider for Visual FoxPro;Data Source=n:\tsnoffice\a001\"
    sqlStr = "SELECT * FROM A_52"
    Set conn = CreateObject("ADODB.Connection")
    Set recSet = CreateObject("ADODB.Recordset")
    'Set conn = ActiveDocument.MailMerge
    conn.Open conStr
    recSet.Open sqlStr, conn, adOpenStatic
    MsgBox CStr(recSet.RecordCount)

    End Sub

    Is there another way I should be approaching this?

    Last edited by sreece; 12-21-05 at 16:23. Reason: Mistaken code...

  2. #2
    Join Date
    Jul 2003
    Amsterdam, Nederland

    Talking Fox pro

    Be sure your cursor and location are set wright

    FileConnStr = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=" & Database
    Connection.ConnectionString = FileConnStr
    Connection.CursorLocation = adUseServer

    RS.CursorLocation = adUseServer
    RS.CursorType = adOpenKeyset
    RS open = xxxx


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts