Luca
Luca

Reputation: 69

Report ignores parameter when I open the report from a form

I have a very simple table, AssemblyTree with 4 fields, [ID], [L1], [L2] and [L3]. I have created a simple query:

SELECT * FROM AssemblyTree WHERE [AssemblyID] Like "*" & [Forms]![AssemblyForm]![invenbox].[Text] & "*";

This is the query is the record source for my report. Now, if I open the report by double clicking on it, it prompts me for the parameter value. I type it in and it works perfectly, displaying only the [L1], [L2], [L3] for the ID I typed.

On my AssemblyForm, I have a text box, named invenbox, and a button. The user is meant to type the AssemblyID that they want to see a report of in the textbox, and click the button to open the report. The VBA code on the button is simply: DoCmd.OpenReport "TreeReport", acViewPreview And this is where my issue arises. When I type in the same AssemblyID, 100, in the textbox and click the button to open the report, it doesn't only show the ID I specified, but all the IDs in the table(100, 101, 103 are the only IDs in the table). What the report should do is only show me the information about the ID which I typed. How can I get this to work? The report should only show the L1, L2, L3 of the ID I selected (100 in this example) and not L1, L2, L3 of any other[2]

Upvotes: 0

Views: 19

Answers (1)

dbmitch
dbmitch

Reputation: 5386

You don't need and shouldn't be using the Text property

Just use [Forms]![AssemblyForm]![invenbox] in your query

Upvotes: 1

Related Questions