Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Supplying parameters to queries (Access XP)

    I have a report that uses a query and that query uses a query that needs a parameter.
    If the SEARCH function were available I would not be asking this question.
    I have done this before but as is always the case I cannot remember which database I have done it in.

    Can you just refer to a query and supply it the parameters via xxx.Parameter before kicking off the report?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Supplying parameters to queries (Access XP)

    If the parameter query is nested in the query the report uses as its recordsource, no. When reports run, they create a new instance of the query behind the report, so you would have to pass the parameter in again and you can't do it from code. You could change the query to refer to a control on a form for the parameter value. That's the cleanest way with reports. With a regular query being run in code, you can pass a parameter in if the nested parameter query actually has the item in its parameters clause.

    Wait, let me think about that. <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> XP reports expose the recordset property of the report, so you might be able to open the recordset in code and then set the report's recordset property to that recordset. I haven't tried it, but that would allow you to pass the parameter in code by populating a querydef object and then opening a recordset on that querydef.
    Charlotte

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Supplying parameters to queries (Access XP)

    Thanks Charlotte, I have gone with the form parameter.
    I haven't tried your second suggestion, but it looks like it's worth a try. This would be very handy if it works.

Posting Permissions

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