Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    311

    Unanswered: passing a qry name to a rs.open method

    i would like to execute a query in a module and then use the record set to analyse the info.

    Normally when using sql i would :
    RS.Open SQL, cn, 1 ' 1 = adOpenKeyset

    I recall something in vb like :

    Private Sub cmdAnalSolCKs_Click()

    Dim cn As Connection
    Dim RS As Recordset
    Set cn = Application.CurrentProject.Connection
    Set RS = CreateObject("ADODB.Recordset")

    cn.open
    rs.connection = cn

    rs= cn.execute("myQryName")

    End Sub


    But i cant fiqure it out in vba

    Big help needed !

    By the way i dont want to use dao and the forms rs (form doesnt have one )

    tnks 1,000,000

    M~

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: passing a qry name to a rs.open method

    Originally posted by mikezcg
    i would like to execute a query in a module and then use the record set to analyse the info.

    Normally when using sql i would :
    RS.Open SQL, cn, 1 ' 1 = adOpenKeyset

    I recall something in vb like :

    Private Sub cmdAnalSolCKs_Click()

    Dim cn As Connection
    Dim RS As Recordset
    Set cn = Application.CurrentProject.Connection
    Set RS = CreateObject("ADODB.Recordset")

    cn.open
    rs.connection = cn

    rs= cn.execute("myQryName")

    End Sub


    But i cant fiqure it out in vba

    Big help needed !

    By the way i dont want to use dao and the forms rs (form doesnt have one )

    tnks 1,000,000

    M~
    I'm trying to figure out whether or not you want to use DAO. Is it just the dependency on the form recordset or the DAO?

    DAO would be:

    Dim db as database, rs as recordset

    Set db = CurrentDb
    Set rs = db.OpenRecordset("queryname", dbOpenDynaset)

    Then check that you have something in the recordset by checking the recordcount property or BOF And EOF.

    I don't think you're going to find recordset processing in VBA. ADO or DAO I believe are your choices.

Posting Permissions

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