How to get data from an existing query in access using VB5 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Guilherme2011
    New Member
    • Sep 2010
    • 1

    #1

    How to get data from an existing query in access using VB5 ?

    Hi all.

    I have a database (agenda.mdb) with a table called "movimentac oes"

    In access I created a query named "RESULATODT AB" wich is a cross-tab query.

    I want my program to check that query and return all the results from it to a list in visual basic called lstresultados.

    What I have so far is a code to run the query(thanks Paul):

    Dim strConnectionSt ring As String
    Dim objConn As ADODB.Connectio n
    Dim objCommand As ADODB.Command

    strConnectionSt ring = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=f:\visua l basic meus programas\nova pasta\agenda.md b;" & _
    "Jet OLEDB:Engine Type=4"

    Set objConn = New ADODB.Connectio n
    objConn.Open strConnectionSt ring

    Set objCommand = New ADODB.Command

    objCommand.Acti veConnection = objConn

    ' Assign to ADO Command object
    objCommand.Comm andText = "resultaodt ab"
    objCommand.Comm andType = adCmdStoredProc

    objCommand.Exec ute

    objConn.Close

    Set objCommand = Nothing
    Set objConn = Nothing

    Can anyone please help me ?
Working...