Use form to select criteria for report

R

robnsd

I want to use a form with a combo box so the user can select a name
from a drop down box to open a report. The report will open using that
name as the parameter. Currently I use a parameter query where the
user must type in the name but a drop down box with a list of names
would be preferable.

I have created the form "frmStaffNames", the unbound combo box
"cboCashierNames"

My report name is "Summary"

I'm stuck

Thanks for any help.

Robert
 
G

Guest

Hi Robert,

It sounds like you are so very close to getting this to work correctly!
Perhaps you will find this example helpful:

http://home.comcast.net/~tutorme2/samples/customdialogbox.zip

What is the row source for your combo box? In other words, does it include
only people's names, or does it perhaps also include a hidden primary key
column, with column count > 1? You can use the optional WhereCondition
parameter of the DoCmd.OpenReport method. If the key is text-based, then you
need to wrap it in quotes. See this additional example for printing the
active record displayed on a form:

How to print only one page of a multipage report
http://www.access.qbuilt.com/html/reports.html#PrintOnePgOfRpt


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
G

Guest

Take the parameter out of your query.

Open the report like this:

DoCmd.OpenReport "Summary",,,"[MyName] = '" & cboCashierNames & "'"

The above assumes that your combo is populated with names and not ID's.
[MyName] is the field in your query/report that contains the name.
cboCashierNames as used above will return the value of the first non-zero
width column of the combo.

Try it and post back if you have any problems...

Steve
 
G

Guest

Hi Steve,
cboCashierNames as used above will return the value of the first non-zero
width column of the combo.

cboCashierNames, as used above, will return the value of the bound column,
irregardless of it's width.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

SteveM said:
Take the parameter out of your query.

Open the report like this:

DoCmd.OpenReport "Summary",,,"[MyName] = '" & cboCashierNames & "'"

The above assumes that your combo is populated with names and not ID's.
[MyName] is the field in your query/report that contains the name.
cboCashierNames as used above will return the value of the first non-zero
width column of the combo.

Try it and post back if you have any problems...

Steve
 
G

Guest

You are quite right of course...
I made an edit to my post and missed a peice of info, it should have read:

cboCashierNames as used above will return the value of the bound column even
though it displays the first non-zero width column of the combo.

Steve

Tom Wickerath said:
Hi Steve,
cboCashierNames as used above will return the value of the first non-zero
width column of the combo.

cboCashierNames, as used above, will return the value of the bound column,
irregardless of it's width.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

SteveM said:
Take the parameter out of your query.

Open the report like this:

DoCmd.OpenReport "Summary",,,"[MyName] = '" & cboCashierNames & "'"

The above assumes that your combo is populated with names and not ID's.
[MyName] is the field in your query/report that contains the name.
cboCashierNames as used above will return the value of the first non-zero
width column of the combo.

Try it and post back if you have any problems...

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top