Combo box filter on continuous form

S

sunberries

I'm working on a continuous form, with a query as the record source. I
assigned an event for a combo box named [Combodate], I wanted this combo box
to filter the form's date field based on the selection made. I placed this
combo box on the Header and used a Getfocus and ApplyFilter macro where the
event for the combo box is:

Afterupdate, Get Focus : [DateA]
Applyfilter, Where Condition: ([DateA]=[ComboDate])

But this setting kept popping out an "Enter parameter value - combodate"
box - which I have to type in the date value even though I selected it from
the combo
already.....it does filter this way but it beats the purpose of the combo box.
It seems like the macro could'nt find the [comboDate] in the form..because
even if I rename or place the combo box in the details section, the dialogue
box keeps popping out.
 
J

John Vinson

I'm working on a continuous form, with a query as the record source. I
assigned an event for a combo box named [Combodate], I wanted this combo box
to filter the form's date field based on the selection made. I placed this
combo box on the Header and used a Getfocus and ApplyFilter macro where the
event for the combo box is:

Afterupdate, Get Focus : [DateA]
Applyfilter, Where Condition: ([DateA]=[ComboDate])

But this setting kept popping out an "Enter parameter value - combodate"
box - which I have to type in the date value even though I selected it from
the combo
already.....it does filter this way but it beats the purpose of the combo box.
It seems like the macro could'nt find the [comboDate] in the form..because
even if I rename or place the combo box in the details section, the dialogue
box keeps popping out.

I don't use macros so I'm not certain, but I think you're missing two
things: the full control reference and the required # date delimiters.
Try

Where Condition: [DateA] = "#" & Forms![YourFormName]![ComboDate] &
"#"

Or do it in VBA:

Private Sub ComboDate_AfterUpdate()
If IsNull(Me!ComboDate) Then
Me.Filter = ""
Me.FilterOn = False
Else
Me.Filter = "[DateA] = #" & Me![ComboDate] & "#"
Me.FilterOn = True
End If
End Sub


John W. Vinson[MVP]
 
S

sunberries

Thanks, the complete reference path at the right side of the "where
condition" was actually missing and that was the cause of the problem.

For other users using macros, it will look like this on the where condition;
([DateA]=[Forms]! [formname]![comboDate])
 
Top