passing parameter to a query from report

access Nepal
  • 13 years ago

    hi all,

    I have created a report which is bound to a parameterized query(at run time using VBA). it displays teh report but asks for the paramter.

    What i want is I want to input parameter in a textbox and upon clicking on the command button , it will show the report with the parameter in the textbox.

    thank you

  • 13 years ago

    Hi,

    First of all open the query in design view and in the criteria of the field you want add a reference to the form text box ex: Forms![Results]![txtResult] (where Results is the form name and txtResult is the text box name). Now just create a button and on click event write the below function:

    DoCmd.OpenReport "ResultsReport", acViewPreview (where ResultsReport is the report name), and that is it.

    I fyou mean that query is not physically available add the text box reference to the sql query ex:

    SELECT Shortcuts.Term
    FROM Shortcuts
    WHERE (((Shortcuts.Term)=[Forms]![Results]![txtResult]));



    Hope this what you were looking for.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan