Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Posts
    2

    Unanswered: GoToRecord in a recordset

    I'm trying to access a specific record in a recordset based off of the numerical value in the field of another recordset. Below is the code I have written:


    Set conn1 = CurrentProject.Connection

    rs.Open "SELECT * FROM AllAMBestCompanies", conn1
    rs1.Open "Select * From AllAMBESTCompanies_ImportErrors", conn1
    rs1.MoveFirst

    Do While Not rs1.EOF
    DoCmd.GoToRecord , "rs", acGoTo, rs1!Row
    Loop


    However, when trying to execute the code, I get the following error:


    "The object 'rs' isn't open"


    Am I missing a step in opening the "rs" recordset or can you not access a specific record in a recordset in this manner?

    Thanks for any words of wisdom!

  2. #2
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    Try this first.....

    Dim db As Database
    Dim rs As Recordset. rs1 as Recordset
    Dim strSQL As String, strSQL1 as String
    Dim myCount As Integer
    Dim rsCount As Integer

    Set db = CurrentDb()
    strSQL = ""SELECT * FROM AllAMBestCompanies"
    strSQL1 = "Select * From AllAMBESTCompanies_ImportErrors"
    Set rs = db.OpenRecordset(strSQL)
    Set rs1 = db.OpenRecordset(strSQL1)

    rs1.MoveFirst

    Do While Not rs1.EOF
    DoCmd.GoToRecord , "rs", acGoTo, rs1!Row
    Loop


    'close recordset
    rs.Close
    rs1.Close
    Set db = Nothing


    Step through your code with F8 to see where the code exactly hangs.

    Hope this helps....

Posting Permissions

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