Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Location
    Philadelphia, PA
    Posts
    14

    Question Unanswered: how do you dynamically set a report's recordset?

    Hello,

    I've got a simple report in Access XP that could display data from one of two queries. What I'd like to do is open the report and attach the right data to it, depending on what was asked by the user. The data is coming from a stored procedure on SQL Server that has input parameters (hence the varying data). The recordset schema that is returned is always the same, of course.
    Access tells me that I can't set a recordset or recordsource property once the report has been displayed. So I tried to instantiate something (Set rpt = New Report_thereport) and set its recordset that way, then making it visible. No luck, as the report opens at instantiation.

    I'm probably missing something obvious that you experienced Access people can tell me. Any help would be very much appreciated,

    Tim

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    Set recordsource options for report in the on open event of the report itself.

  3. #3
    Join Date
    May 2002
    Location
    Philadelphia, PA
    Posts
    14
    That's what I had been thinking.
    So I had a go with this kind of thing:

    DoCmd.OpenReport "thereport", acViewPreview, , , acWindowNormal, "one"

    Private Sub Report_Open(Cancel As Integer)
    Dim s As Variant
    s = Me.OpenArgs
    If s = "one" Then Me.RecordSource = "exec sprocname 1"
    End Sub

    But the OpenArgs was null (not "one") , so that didn't work.
    I'm probably doing something silly with OpenArgs, but after consulting various docs it's still not clear what's going on.

    Perhaps that should have been my original question....

  4. #4
    Join Date
    Feb 2002
    Posts
    403
    Tim

    I haven't used openargs much previously, so when I got Access XP I thought I would try them out. I couldn't get them to work, so I ordered a new book, which still hasn't arrived as I decided I was missing something too. I'm wondering if the open args syntax or something has changed since 2000, as all my reference material is for 2000.

Posting Permissions

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