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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|