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  

Adding command buttons to filter and reset



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2006, 07:54 PM posted to microsoft.public.access.forms
rpbsr
external usenet poster
 
Posts: 47
Default Adding command buttons to filter and reset

I would like to place command buttons on a form to take the place of "filter
by form", "apply filter", and "remove filter" buttons on the menu bar. Can
macros be written for these functions? If not, is there another way?

Thanks for any help.

Robert
  #2  
Old December 22nd, 2006, 04:03 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Adding command buttons to filter and reset

The problem with that approach is that when you are Filter-By-Form (FBF)
mode, all command buttons are disabled, so their code/macros cannot run.

You can therefore enter Filter-By-Form with a command button:
RunCommand acCmdFilterByForm
but you can't get back again with a command button.

There are alternative ways of creating your own filters. In fact, FBF
doesn't work in the runtime/mde, so developers usually do create their own
alternatives. If you are interested, there's a downloadable example that
goes with this article:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rpbsr" wrote in message
...
I would like to place command buttons on a form to take the place of
"filter
by form", "apply filter", and "remove filter" buttons on the menu bar. Can
macros be written for these functions? If not, is there another way?

Thanks for any help.

Robert



  #3  
Old December 22nd, 2006, 03:04 PM posted to microsoft.public.access.forms
rpbsr
external usenet poster
 
Posts: 47
Default Adding command buttons to filter and reset

Allen - that describes my problem exactly. Thanks for the tip; I'll check it
out.

Robert

"Allen Browne" wrote:

The problem with that approach is that when you are Filter-By-Form (FBF)
mode, all command buttons are disabled, so their code/macros cannot run.

You can therefore enter Filter-By-Form with a command button:
RunCommand acCmdFilterByForm
but you can't get back again with a command button.

There are alternative ways of creating your own filters. In fact, FBF
doesn't work in the runtime/mde, so developers usually do create their own
alternatives. If you are interested, there's a downloadable example that
goes with this article:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rpbsr" wrote in message
...
I would like to place command buttons on a form to take the place of
"filter
by form", "apply filter", and "remove filter" buttons on the menu bar. Can
macros be written for these functions? If not, is there another way?

Thanks for any help.

Robert




  #4  
Old December 22nd, 2006, 07:55 PM posted to microsoft.public.access.forms
rpbsr
external usenet poster
 
Posts: 47
Default Adding command buttons to filter and reset

Allen,
I reviewed the article, but I'm not very familiar with VB. Below is the
code that resulted from the command buttons I placed. Is there a simpler way
for this simple application? Perhaps a way to modify the first procedure so
the buttons remain enabled?

Thanks

Private Sub Command12_Click()
On Error GoTo Err_Command12_Click

Dim stDocName As String

stDocName = "filter by form"
DoCmd.RunMacro stDocName

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String

stDocName = "apply filter"
DoCmd.RunMacro stDocName

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click

Dim stDocName As String

stDocName = "remove filter"
DoCmd.RunMacro stDocName

Exit_Command14_Click:
Exit Sub

Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click

End Sub



"Allen Browne" wrote:

The problem with that approach is that when you are Filter-By-Form (FBF)
mode, all command buttons are disabled, so their code/macros cannot run.

You can therefore enter Filter-By-Form with a command button:
RunCommand acCmdFilterByForm
but you can't get back again with a command button.

There are alternative ways of creating your own filters. In fact, FBF
doesn't work in the runtime/mde, so developers usually do create their own
alternatives. If you are interested, there's a downloadable example that
goes with this article:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rpbsr" wrote in message
...
I would like to place command buttons on a form to take the place of
"filter
by form", "apply filter", and "remove filter" buttons on the menu bar. Can
macros be written for these functions? If not, is there another way?

Thanks for any help.

Robert




  #5  
Old December 23rd, 2006, 01:37 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Adding command buttons to filter and reset

"rpbsr" wrote in message
...
Allen,
I reviewed the article, but I'm not very familiar with VB. Below is the
code that resulted from the command buttons I placed. Is there a simpler
way
for this simple application? Perhaps a way to modify the first procedure
so
the buttons remain enabled?


No. As explained, no code or macros can execute from the form while it is in
FBF.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


 




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:14 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.