A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need form filtered based on criteria



 
 
Thread Tools Display Modes
  #1  
Old May 6th, 2008, 09:24 PM posted to microsoft.public.access.forms
Destin Richter
external usenet poster
 
Posts: 22
Default Need form filtered based on criteria

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

  #2  
Old May 6th, 2008, 10:35 PM posted to microsoft.public.access.forms
Derek[_6_]
external usenet poster
 
Posts: 6
Default Need form filtered based on criteria

Hi
I have no idea but would love to know why you cannot use query


"Destin Richter" wrote in message
...
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


  #3  
Old May 7th, 2008, 12:05 AM posted to microsoft.public.access.forms
Damon Heron[_2_]
external usenet poster
 
Posts: 237
Default Need form filtered based on criteria

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


"Destin Richter" wrote in message
...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:44 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.