to Filter or not to Filter option not working...

  • Thread starter Thread starter Mark Kubicki
  • Start date Start date
M

Mark Kubicki

i had a from with a combobox: cmbFilter
and this code behind it...

cmbFilter_BeforeUpdate()
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True

this worked fine...

then i added an option group with 2 controls: optShowAll, and optFilterList
(with respective functions)

and added this code behind each:

optShowAll_GotFocus()
me.cmbFilter.enabled = False
me.FilterON = False

optFilterList_GotFocus()
me.cmbFilter = ""
me.cmbFilter.enabled = True

now, basically nothing works... (what am i missing - any suggestions wouldbe
greatly appreciated)
thanks in advance,
-m.
 
I think this is what you are trying to do:

If Me.Dirty Then Me.Dirty = False 'Save any edits
If (Me.Frame1 = Me.optShowAll.OptionValue) _
Or IsNull(Me.cmbFilter) Then
Me.FilterOn = False
Else
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True
End If
 
behind what event should this be? (form_current?)
Allen Browne said:
I think this is what you are trying to do:

If Me.Dirty Then Me.Dirty = False 'Save any edits
If (Me.Frame1 = Me.optShowAll.OptionValue) _
Or IsNull(Me.cmbFilter) Then
Me.FilterOn = False
Else
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True
End If

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

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

Mark Kubicki said:
i had a from with a combobox: cmbFilter
and this code behind it...

cmbFilter_BeforeUpdate()
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True

this worked fine...

then i added an option group with 2 controls: optShowAll, and
optFilterList (with respective functions)

and added this code behind each:

optShowAll_GotFocus()
me.cmbFilter.enabled = False
me.FilterON = False

optFilterList_GotFocus()
me.cmbFilter = ""
me.cmbFilter.enabled = True

now, basically nothing works... (what am i missing - any suggestions
wouldbe greatly appreciated)
thanks in advance,
-m.
 
Since the results depend on the combo and the option group, it would need to
be in the AfterUpdate of both.

If I've understood you correctly, I'm not sure the option group is really
needed. You could unset the filter (show all records) if the user clears the
unbound combo (i.e. if it is null.)

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

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

Mark Kubicki said:
behind what event should this be? (form_current?)
Allen Browne said:
I think this is what you are trying to do:

If Me.Dirty Then Me.Dirty = False 'Save any edits
If (Me.Frame1 = Me.optShowAll.OptionValue) _
Or IsNull(Me.cmbFilter) Then
Me.FilterOn = False
Else
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True
End If

Mark Kubicki said:
i had a from with a combobox: cmbFilter
and this code behind it...

cmbFilter_BeforeUpdate()
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True

this worked fine...

then i added an option group with 2 controls: optShowAll, and
optFilterList (with respective functions)

and added this code behind each:

optShowAll_GotFocus()
me.cmbFilter.enabled = False
me.FilterON = False

optFilterList_GotFocus()
me.cmbFilter = ""
me.cmbFilter.enabled = True

now, basically nothing works... (what am i missing - any suggestions
wouldbe greatly appreciated)
thanks in advance,
-m.
 
really !?! thanks.
Allen Browne said:
Since the results depend on the combo and the option group, it would need
to be in the AfterUpdate of both.

If I've understood you correctly, I'm not sure the option group is really
needed. You could unset the filter (show all records) if the user clears
the unbound combo (i.e. if it is null.)

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

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

Mark Kubicki said:
behind what event should this be? (form_current?)
Allen Browne said:
I think this is what you are trying to do:

If Me.Dirty Then Me.Dirty = False 'Save any edits
If (Me.Frame1 = Me.optShowAll.OptionValue) _
Or IsNull(Me.cmbFilter) Then
Me.FilterOn = False
Else
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True
End If

i had a from with a combobox: cmbFilter
and this code behind it...

cmbFilter_BeforeUpdate()
Me.Filter = "[Source] = '" & Me![cmbFilter] & "'"
Me.FilterOn = True

this worked fine...

then i added an option group with 2 controls: optShowAll, and
optFilterList (with respective functions)

and added this code behind each:

optShowAll_GotFocus()
me.cmbFilter.enabled = False
me.FilterON = False

optFilterList_GotFocus()
me.cmbFilter = ""
me.cmbFilter.enabled = True

now, basically nothing works... (what am i missing - any suggestions
wouldbe greatly appreciated)
thanks in advance,
-m.
 
Back
Top