View Full Version : Open report with criteria


fluidmind
07-20-2006, 07:48 AM
Hi folks!

When you fx make a button to open another form, you can choose to open it only containing data where a variable is equal to fx a textbox in the form where the open-form-button is placed.

That's what I want my report to do too. But i don't get that option, when I create an open-report-button. I want to open a report containing emplyee-stats, but I only want the report to show the stats for the selected employee. I know it can be done... But how?

// JR

Jibbadiah
07-20-2006, 08:02 AM
Go to the query for the report and put forms!Formname!txtEmployee in the criteria section. Where Formname is the name of your form calling the report, and txtEmployee is the text control with the employee id.

Matt Greatorex
07-20-2006, 08:04 AM
Under DoCmd.OpenReport within Access help is a pretty helpful explanation of how to use filters when opening reports, via VBA. (It must be clear if I was able to use it ;) ).

You can either save a filter, or use a string (e.g. "name = 'Smith'").
That would allow you to pick a name from a list on some form and to construct the string, before using the OpenReport command.

Hope that helps.

fluidmind
07-20-2006, 08:34 AM
Hi guys!

Thanks for your replies... And so quickly - WAW! It tried you version suggestion first, Matt - It seemed easier. But I couldn't get it to work (probably did something wrong :-)).

Jibbadiah - Your suggestion was the winner :-)

Thanks again!