How do I base a query on a report, in a form button?

JimJones

Registered User.
Local time
Today, 02:11
Joined
May 6, 2003
Messages
78
Hi,

I want to open a report in preview mode, that displays the
complete history on the displayed employee, NOT all the employees.

But, when I click my command button, it displays the report, listing all the employees.

I think the problem is in the criteria of my query.
I don't like using the filter method, because frankly, I think it's
too confusing, and I'm going to give this database for someone to use, on a daily basis.

So, in my employee id column, in the query, what else is needed,
to 'filter' for just the currently displayed employee record?

Thanks,
Jim
 
You are correct, it is your criteria you need to set.

Try using the expression builder to set your criteria.
 
Rather than modifying your query, use the "where" argument of the OpenForm method.
 
Thank you both.

Indeed, I did end up modifying my query criteria.

In the query criteria field, I made the expression to point
to the value of the current employee record, on the main form.

This gave me exactly what I want, for the report.

Thanks,
Jim
 
Glad to hear you got what you needed.
 
Old question revisited - command buttons and specific criteria

JimJones said:
Thank you both.

Indeed, I did end up modifying my query criteria.

In the query criteria field, I made the expression to point
to the value of the current employee record, on the main form.

This gave me exactly what I want, for the report.

Thanks,
Jim

I am in need of the same thing; how did you point to the value of the current employee record on the main form???

Thanks,

Jason
 
Do something like this in the OnClick code:

Code:
    Dim stDocName As String
    Dim stWherest As String
    
    stDocName = "Name of my report"
    stWherest = "[MyTable]![MyField]= Forms![MyForm]![MyField]"

    DoCmd.OpenReport stDocName, acPreview, , stWherest

....just replace the My* with the names of your reports, tables and forms.
 

Users who are viewing this thread

Back
Top Bottom