Hi, I have a main form, based on a table (not a query, and that won't
change). Need code behind a new command button that filters my form such
that any record with the field "Current" (yes/no) set to Yes shows up. Will
make another command button to show No only, and another to remove the filter
(showing all). Can you provide the code I need? Assume tblEmployees and
frmEmployees are components.
Thank you!
Destin Richter
richter@newmexico.com
Derek - 06 May 2008 22:35 GMT
Hi
I have no idea but would love to know why you cannot use query
> Hi, I have a main form, based on a table (not a query, and that won't
> change). Need code behind a new command button that filters my form such
[quoted text clipped - 9 lines]
> Destin Richter
> richter@newmexico.com
Damon Heron - 07 May 2008 00:05 GMT
You could certainly use the filter property to do this: put an option group
with three choices on your frmEmployees, calling it frameCurrent, and a
value of 1,2,3 for the options. Have one command button (called cmdFilter in
this example). there should also be a control with the source of "Current"
on the form. (this is untested code, but it should get you started)
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click
select case (Me.frameCurrent.Value)
case 1
me.filter= "[Current]= Yes"
me.filteron=true
case 2
me.filter= "[Current]= No"
me.filteron=true
case 3
me.filteron= false
end select
Exit_cmdFilter_Click:
Exit Sub
Err_cmdFilter_Click:
MsgBox Err.Description
Resume Exit_cmdFilter_Click
End Sub
> Hi, I have a main form, based on a table (not a query, and that won't
> change). Need code behind a new command button that filters my form such
[quoted text clipped - 9 lines]
> Destin Richter
> richter@newmexico.com