Visual Basic Databases

Iam using multiple tables and hence using queries to use data from these tables. I would like to know as to how I can use query Defs to make my code faster?


Comments

  • : Iam using multiple tables and hence using queries to use data from these tables. I would like to know as to how I can use query Defs to make my code faster?


    I myself use recordset and find them to be fast and simple to work with. The key is to create the SQL statement. Wait one Access can make this simple for you create a query and cut out the SQL from it and paste into the statement. You can use program control to change the string as needed to get what you need. The following code might help:

    Dim rs As Recordset

    Dim db As Database

    Dim sDataBase As String

    Dim sData As String

    sDataBase= "C:pathfilename.mdb"

    Set db = DBEngine(0).OpenDatabase(sDataBase)

    sData= "SELECT....." 'The SQL statement

    Set rs = db.OpenRecordset(sData)

    If rs.EOF Then

    rs.Close

    Exit Sub

    End If

    rs.MoveFirst

    Do Until rs.EOF

    'Add code to use the record here

    rs.MoveNext

    Loop

    rs.Close


    URL:617.html

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories