Combol Box and Report

G

Guest

I have a combo box that listed the Department Names. I would like to create a
Print View button that will show only the Department which I selected in the
combo box.

Is possible to do that?

Please help.

Thanks
Chi

Chi
 
F

fredg

I have a combo box that listed the Department Names. I would like to create a
Print View button that will show only the Department which I selected in the
combo box.

Is possible to do that?

Please help.

Thanks
Chi

Chi

Here is one method.
Add a command button to your form
Code it's click event:

DoCmd.OpenReport "ReportName", acViewPreview, , "[Department] = '" &
Me![cboDepartment] & "'"

The above assumes that [Department] datatype is Text.

If [Department] is a Number Datatype, then use:
"[Department] = " & Me![cboDepartment]
 
G

Guest

Hi Fred,
Thanks for your respond. I have tried to apply the code to the form.
However, I got the Code Error message. Would you mind checking the code? It
has problem at the end of line. Sorry, I have no experience using the VBA.

Did I respond to the newsgroup? There are two REPLY buttons, so I am not
sure which one I should use.
Thanks
Chi


fredg said:
I have a combo box that listed the Department Names. I would like to create a
Print View button that will show only the Department which I selected in the
combo box.

Is possible to do that?

Please help.

Thanks
Chi

Chi

Here is one method.
Add a command button to your form
Code it's click event:

DoCmd.OpenReport "ReportName", acViewPreview, , "[Department] = '" &
Me![cboDepartment] & "'"

The above assumes that [Department] datatype is Text.

If [Department] is a Number Datatype, then use:
"[Department] = " & Me![cboDepartment]
 
F

fredg

Hi Fred,
Thanks for your respond. I have tried to apply the code to the form.
However, I got the Code Error message. Would you mind checking the code? It
has problem at the end of line. Sorry, I have no experience using the VBA.

Did I respond to the newsgroup? There are two REPLY buttons, so I am not
sure which one I should use.
Thanks
Chi

fredg said:
I have a combo box that listed the Department Names. I would like to create a
Print View button that will show only the Department which I selected in the
combo box.

Is possible to do that?

Please help.

Thanks
Chi

Chi

Here is one method.
Add a command button to your form
Code it's click event:

DoCmd.OpenReport "ReportName", acViewPreview, , "[Department] = '" &
Me![cboDepartment] & "'"

The above assumes that [Department] datatype is Text.

If [Department] is a Number Datatype, then use:
"[Department] = " & Me![cboDepartment]

Did you change "ReportName" to the actual name of the report you wish
to open?
Did you change [Department] to the actual name of the field in the
report's recordd source?
Did you change [cboDepartment] to the actual name of the combo box on
the form?
Did you use the Text or Number datatype syntax as explained in my
previous message.

A copy of YOUR exact code would have been helpful.
 

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

Similar Threads


Top