Solved

SELECT WHERE with Foxpro Db from VB6

Posted on 1998-12-01
3
421 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
Comment Utility
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
Comment Utility
' 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
Comment Utility
That got me started - thanks!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now