Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47

    Unanswered: Parameter Querys from code

    I have a report based on a parameter query (includes [startdate] and [enddate]). How do I open the report from a form and supply the parameters based on value of controls on the form?

    Thanks

  2. #2
    Join Date
    Apr 2003
    Location
    Washington DC area
    Posts
    1,770

    Talking Re: Parameter Querys from code

    You have a form that activates a report, that activates a query, which also needs input parameters? Is this what your looking for.

    Originally posted by nstaward
    I have a report based on a parameter query (includes [startdate] and [enddate]). How do I open the report from a form and supply the parameters based on value of controls on the form?

    Thanks

  3. #3
    Join Date
    Mar 2003
    Location
    Bucharest, Romania
    Posts
    80

    Re: Parameter Querys from code

    Instead [startdate] parameter, use this:
    [Forms]![Your_form_name]![txtStartDate], where txtStartDate is the name of the textbox control from which you want the value to be taken and asigned as a criteria to the query


    ionut

  4. #4
    Join Date
    Aug 2002
    Location
    Cambridge, England
    Posts
    47

    Re: Parameter Querys from code

    Originally posted by ionut calin
    Instead [startdate] parameter, use this:
    [Forms]![Your_form_name]![txtStartDate], where txtStartDate is the name of the textbox control from which you want the value to be taken and asigned as a criteria to the query


    ionut
    Yeah I already had that but wondered if there was another way, whcih would then allow the same report to be opened by different forms. But nevermind, works well enough how it is.

    Thanks

  5. #5
    Join Date
    Oct 2002
    Posts
    61

    Change the Data Source of the Report

    Have the form change the data source of the report. You can get real fancy and write the SQL into the event code for the button on the form that will run the report.

    Good Luck

  6. #6
    Join Date
    Mar 2003
    Location
    Bucharest, Romania
    Posts
    80

    Re: Change the Data Source of the Report

    You can modify SQL for the report in the click event of a button on the form, is true. But if your query is a long one (in terms of charachters that compose the select syntax) it could take a very long time to complete the change. Trust me, I've seen reports for which the change of sql statement through VBA code, last for almost a minute (on a Athlon 1G machine, 256 MB memory and Access 2000 installed).
    Unfortunately there is no other way of reusing the same report with several forms, because:

    1) you can set parameters of a query before opening it, through VBA code (use ADOX objects, or DAO if you want) and open the query as as recordset

    2) THE BIG PROBLEM WITH ACCESS IS THAT YOU CAN'T SET THE RECORDSOURCE OF A REPORT TO AN EXISTING RECORDSET OBJECT (ADO or DAO for that matter). Why not? Only Bill can answer it!.

    ionut

Posting Permissions

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