Solved

SELECT WHERE with Foxpro Db from VB6

Posted on 1998-12-01
3
425 Views
Last Modified: 2013-12-25
I need to create a recordset such as the following:  SELECT * FROM Table1 WHERE Status = "OPEN"   ...but the "table" is a Foxpro .dbf.  I can access the file and use all the records, but I just want a subset.  SQL Server or Access wouldn't be a problem, but I can't seem to find the right method to use this filtering with an ISAM file.  

What's the best way to create a filtered recordset from a Foxpro 2.6 source?
0
Comment
Question by:gglover
3 Comments
 
LVL 3

Expert Comment

by:vbWhiz
ID: 1497925
How are you currently accessing the file and using the records? Are you using DAO? Some sample code would be a good start.
0
 
LVL 3

Accepted Solution

by:
cognition earned 50 total points
ID: 1497926
' I hope the following works for you !

    Dim wrkJet As Workspace
    Dim dbsTest As Database
    Dim rstTemp As Recordset

    ' Create Workspace
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
   
    ' Open Database : Replace path to fox files and fox version
    Set dbsTest = wrkJet.OpenDatabase("o:\viglen data\dbfs\all", True, True, "FoxPro 2.5;")

    ' Create recordset with a select and a where clause
    ' Chaneg SQL to reflect your query
    ' If the filter is a text string then ensure that single quotes are used
    Set rstTemp = dbsTest.OpenRecordset("SELECT * FROM ordline WHERE ion = '393632'", dbOpenForwardOnly)
   
    ' Loop through recordset and print some results
    With rstTemp
        Do While Not .EOF
            Debug.Print .Fields(0), .Fields(1)
            .MoveNext
        Loop
    End With

    rstTemp.Close
    dbsTest.Close
    wrkJet.Close



0
 

Author Comment

by:gglover
ID: 1497927
That got me started - thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question