Combo Box HELP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need some HELP! I have a bound form and added an Unbound Combo Box. The
values are looked up in a a table(SQL query-two fields on grid with 1st field
bound). The box displays the values as it should. When the form opens, all
records are displayed. What I want to do is...

Select a value from the combo box and have the form filtered to match the
selected value in the combo box. I have attached a simple expression on the
AfterUpdate Event to the combo box:

DoCmd.ApplyFilter "", "[Competitive Line] = [Comp]"

When I change a value in the combo box (Unbound and named Comp), I get a
message asking for a Parameter Value. I type in that value and the filter is
applied and works properly. Why am I getting the Enter Parameter Value
message - Comp? It is as if the selected value is not recognized or stored
after I select, but works when I type it in.

Any suggestions or a better way to go about doing what I want?
 
You need to concatenate the value of Comp into the filter string.

Instead of
"[Competitive Line] = [Comp]"
use:
"[Competitive Line] = " & [Comp]
If Competitive Line is a Text field (not a Number field), you need extra
quotes:
"[Competitive Line] = """ & [Comp] & """"

Personally, I prefer to assign this to the Filter property of the form:
Me.Filter = "[Competitive Line] = """ & [Comp] & """"
Me.FilterOn = True
 
I used your example and assigned the two lines of code (paste) to the Filter
property of the form (not On Filter). The first time I selected the value
from the combo box and hit the Apply Filter from the toolbar, I got an error
message about missing operator in expression. However, the Filtered notation
on tthe Navigation bar at the bottom is visible, but All records are filtered
and not the selected value from th combo box. Any suggestions? I feel we're
very close.

Allen Browne said:
You need to concatenate the value of Comp into the filter string.

Instead of
"[Competitive Line] = [Comp]"
use:
"[Competitive Line] = " & [Comp]
If Competitive Line is a Text field (not a Number field), you need extra
quotes:
"[Competitive Line] = """ & [Comp] & """"

Personally, I prefer to assign this to the Filter property of the form:
Me.Filter = "[Competitive Line] = """ & [Comp] & """"
Me.FilterOn = True

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

hdfixitup said:
I need some HELP! I have a bound form and added an Unbound Combo Box. The
values are looked up in a a table(SQL query-two fields on grid with 1st
field
bound). The box displays the values as it should. When the form opens,
all
records are displayed. What I want to do is...

Select a value from the combo box and have the form filtered to match the
selected value in the combo box. I have attached a simple expression on
the
AfterUpdate Event to the combo box:

DoCmd.ApplyFilter "", "[Competitive Line] = [Comp]"

When I change a value in the combo box (Unbound and named Comp), I get a
message asking for a Parameter Value. I type in that value and the filter
is
applied and works properly. Why am I getting the Enter Parameter Value
message - Comp? It is as if the selected value is not recognized or
stored
after I select, but works when I type it in.

Any suggestions or a better way to go about doing what I want?
 
1. Remove the property from the form's On Filter event property.

2. Set the AfterUpdate event property of the combo to:
[Event Procedure]

3. Click the Build button (...) beside this.
Access opens the code window.

4. Put the 2 lines in between the "Private Sub..." and "End Sub" lines.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

hdfixitup said:
I used your example and assigned the two lines of code (paste) to the
Filter
property of the form (not On Filter). The first time I selected the value
from the combo box and hit the Apply Filter from the toolbar, I got an
error
message about missing operator in expression. However, the Filtered
notation
on tthe Navigation bar at the bottom is visible, but All records are
filtered
and not the selected value from th combo box. Any suggestions? I feel
we're
very close.

Allen Browne said:
You need to concatenate the value of Comp into the filter string.

Instead of
"[Competitive Line] = [Comp]"
use:
"[Competitive Line] = " & [Comp]
If Competitive Line is a Text field (not a Number field), you need extra
quotes:
"[Competitive Line] = """ & [Comp] & """"

Personally, I prefer to assign this to the Filter property of the form:
Me.Filter = "[Competitive Line] = """ & [Comp] & """"
Me.FilterOn = True

hdfixitup said:
I need some HELP! I have a bound form and added an Unbound Combo Box.
The
values are looked up in a a table(SQL query-two fields on grid with 1st
field
bound). The box displays the values as it should. When the form
opens,
all
records are displayed. What I want to do is...

Select a value from the combo box and have the form filtered to match
the
selected value in the combo box. I have attached a simple expression on
the
AfterUpdate Event to the combo box:

DoCmd.ApplyFilter "", "[Competitive Line] = [Comp]"

When I change a value in the combo box (Unbound and named Comp), I get
a
message asking for a Parameter Value. I type in that value and the
filter
is
applied and works properly. Why am I getting the Enter Parameter Value
message - Comp? It is as if the selected value is not recognized or
stored
after I select, but works when I type it in.

Any suggestions or a better way to go about doing what I want?
 
You have MADE MY DAY!! Thank you so much for your expertise. Have a GREAT
Day! Thank you again.

Allen Browne said:
1. Remove the property from the form's On Filter event property.

2. Set the AfterUpdate event property of the combo to:
[Event Procedure]

3. Click the Build button (...) beside this.
Access opens the code window.

4. Put the 2 lines in between the "Private Sub..." and "End Sub" lines.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

hdfixitup said:
I used your example and assigned the two lines of code (paste) to the
Filter
property of the form (not On Filter). The first time I selected the value
from the combo box and hit the Apply Filter from the toolbar, I got an
error
message about missing operator in expression. However, the Filtered
notation
on tthe Navigation bar at the bottom is visible, but All records are
filtered
and not the selected value from th combo box. Any suggestions? I feel
we're
very close.

Allen Browne said:
You need to concatenate the value of Comp into the filter string.

Instead of
"[Competitive Line] = [Comp]"
use:
"[Competitive Line] = " & [Comp]
If Competitive Line is a Text field (not a Number field), you need extra
quotes:
"[Competitive Line] = """ & [Comp] & """"

Personally, I prefer to assign this to the Filter property of the form:
Me.Filter = "[Competitive Line] = """ & [Comp] & """"
Me.FilterOn = True

I need some HELP! I have a bound form and added an Unbound Combo Box.
The
values are looked up in a a table(SQL query-two fields on grid with 1st
field
bound). The box displays the values as it should. When the form
opens,
all
records are displayed. What I want to do is...

Select a value from the combo box and have the form filtered to match
the
selected value in the combo box. I have attached a simple expression on
the
AfterUpdate Event to the combo box:

DoCmd.ApplyFilter "", "[Competitive Line] = [Comp]"

When I change a value in the combo box (Unbound and named Comp), I get
a
message asking for a Parameter Value. I type in that value and the
filter
is
applied and works properly. Why am I getting the Enter Parameter Value
message - Comp? It is as if the selected value is not recognized or
stored
after I select, but works when I type it in.

Any suggestions or a better way to go about doing what I want?
 
Back
Top