Re: drop down list within a query?



On Sat, 20 Jan 2007 11:30:01 -0800, Maax wrote:

Hi Fred, i am getting closer to getting this to work I think (when i say I, I
mean us of course).

I have done as suggested and i now get this message "The command or action
'ApplyFilterSort' isn't available now."

when i click ok the report opens up but the filter has obviously not been
applied.

any thoughts ?

Many thanks for all your help this far.

"fredg" wrote:

On Sat, 20 Jan 2007 06:04:00 -0800, Maax wrote:

Hi Fred, i am afraid i am not having any luck with this.
Firstly when i set the column width it reverts back to 0cm;2.54cm. I am not
sure if this is the same (2.54cm being 1 inch?)

Where I live (the U.S.) the width of the column is set in inches.
If you have a 2 column combo box, setting the Column Widths property
to 0";1" will result in hiding the first column and setting the 2nd
column to 1 inch.

You'll have to write whatever values work for you using whatever
measurement system is in your computers default settings.
cm is fine, just make the value large enough to fully show the
customer name.

The above assumes, of course, that your combo box has 2 columns.

Note: if you still have a problem creating the combo box, start all
over. This time use the Combo Box Wizard to create it. Answer it's
questions and it will do all the work for you.


Next when i add the code "me.visible = false" i get an error message,
regarding no such macro as "me"

I suspect you wrote Me.Visible = False directly on the Command Button
Click line.
That's not where it goes.

Display the combo box property ***.
Click on the Event tab.
On the Click event line write:
[Event Procedure]
Then click on the little button with 3 dots that appears on that line.
When the code window opens the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

Me.Visible = False

Close the code window.

Try it now.

"fredg" wrote:

On Tue, 16 Jan 2007 12:40:01 -0800, Maax wrote:

Hi Fred, yes the query will be used for a report. Although your instructions
are clear I am having trouble with this. I will carry on trying though as i
am sure i will get it correct through trial and error.

"fredg" wrote:

*** Snipped ***

You'll need to use a form to do this.

Let's assume it is a CustomerID number you need as criteria.

Make a new unbound form.
Add a combo box that will include the CustomerID field as well as the
CustomerName field.
Make sure the Combo Box Bound Column is the
CustomerID field (the first column)

Set the Column Width property of the combo to
0";1"

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Code the Report's Record Source Query's CustomerID field criteria
line:
forms!ParamForm!ComboBoxName

Code the Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

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

Run the Report.
The report will open the form.

Find the CustomerName in the combo box.
Click the command button.

The report will display just those records for the Customer selected.
When the Report closes it will close the form.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Apply what filter?
You're not applying a filter, you're opening a report which in turn
uses a query as it's record source.

1) Make sure the bound column of the command button is the same
datatype as the column in the query used as criteria, i.e. CustomerID
is the bound column (Long Integer) and[CustomerID] in the query is
Long Integer.

2) Did you correctly code the Report Open event by writing
[Event Procedure] on the Open line and then coding ... similar to what
I wrote about Me.Visible = False in the form click event in my
previous post.

3) Did you also code the report's Close event using the same
technique?

4) Did you write
forms!ParamForm!ComboBoxName
on the criteria line for the correct column in the query? (you must
also change ComboBoxName to whatever your actual combo box name is.)

Remember, the order in which this is run is to open the report, not
the form nor the query. The report then opens the form. You select the
customer name and click the command button. The report previews. You
never see the query.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.