By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,519 Members | 2,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,519 IT Pros & Developers. It's quick & easy.

Using a form (with a combo box) to enter report criteria

P: n/a
I am trying to set up an unbound form to enter report criteria.

I've followed the MS Office Assistance document: "Create a form to
enter report criteria" which describes how to enter data (such as
dates) in a text box. This procedure works fine. However, I also need
to enter data from a combo box and I cannot get this to work. On my
form I've created an unbound combo box named "Name". In the query bound
to the report I've entered the criterion:

[Forms]![Name of unbound form]![Name]

However, this value does not seem to pass to the query and the report.

If I run the query by itself and enter the criteria (date and name) in
Parameter Values dialog boxes, it works.
Thanks for any help you can offer.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 2 Jan 2005 16:09:53 -0800, pe*******@physics.brown.edu wrote:
I am trying to set up an unbound form to enter report criteria.

I've followed the MS Office Assistance document: "Create a form to
enter report criteria" which describes how to enter data (such as
dates) in a text box. This procedure works fine. However, I also need
to enter data from a combo box and I cannot get this to work. On my
form I've created an unbound combo box named "Name". In the query bound
to the report I've entered the criterion:

[Forms]![Name of unbound form]![Name]

However, this value does not seem to pass to the query and the report.

If I run the query by itself and enter the criteria (date and name) in
Parameter Values dialog boxes, it works.
Thanks for any help you can offer.

The below combo box uses a CompanyID field to pass the criteria.
You'll need to adapt it to match your query criteria field names AND
DATATYPE.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
CompanyID field and the Company Name.
Name the Combo Box 'FindCompany'.
Set it's Bound column to 1.
Set the Column Width property to 0";1"

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

In the Report's Record Source [CompanyID] field criteria line write:
forms!ParamForm!FindCompany

Next, code the report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the selection of the Company.
Click the command button and then report will run.
When the report closes, it will close the form.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2

P: n/a
On 2 Jan 2005 16:09:53 -0800, pe*******@physics.brown.edu wrote:
I am trying to set up an unbound form to enter report criteria.

I've followed the MS Office Assistance document: "Create a form to
enter report criteria" which describes how to enter data (such as
dates) in a text box. This procedure works fine. However, I also need
to enter data from a combo box and I cannot get this to work. On my
form I've created an unbound combo box named "Name". In the query bound
to the report I've entered the criterion:

[Forms]![Name of unbound form]![Name]

However, this value does not seem to pass to the query and the report.

If I run the query by itself and enter the criteria (date and name) in
Parameter Values dialog boxes, it works.
Thanks for any help you can offer.


I meant to add, in my previous post that "Name" is a reserved word in
Access/VBA and should not be used as a field or control name.

See the Microsoft KnowledgeBase article for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3

P: n/a
Thanks very much for your help, Fred. That did the trick. The mistake I
made was in putting the criteria line:

forms!ParamForm!FindCompany (using your example)
under Company Name, rather than the bound field, Company ID.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.