Robert.Finch
New member
- Local time
- Today, 13:37
- Joined
- Dec 17, 2008
- Messages
- 7
Hi
I am trying to replicate the Filter By functionality on a custom popup (right click) toolbar. This is not specific to any form or any control on a form but allows a filter to be applied in any selected control.
I started by making the custom property load a filter criteria form called frmFilterBy.
The FilterBy form has a single unbound control named FilterFor.
The FilterFor control has a On Lost Focus event that hides the form then runs the public function FilterBy2
The FilterBy2 Function reads:
Option Compare Database
Public strFilter01 As String
Public strFilter02 As String
Public strFilter03 As String
Public strFilter04 As String
Public strFilter05 As String
strFilter02 = Screen.ActiveControl.ControlSource
strFilter01 = Screen.ActiveForm.Name
strFilter03 = Screen.ActiveForm.Name & "." & Screen.ActiveControl.Name
strFilter04 = Forms!frmfilterby.FilterFor
MsgBox strFilter01 (02,03,04) (this is just for development checking purposes)
DoCmd.FindRecord [Forms]![frmfilterby]![FilterFor], acEntire, False, , False, acCurrent, (True This finds the first matching record)
strFilter05 = Screen.ActiveControl.ControlSource & " Like " & [Forms]![frmfilterby]![FilterFor]
MsgBox strFilter05 (Check)
DoCmd.RunCommand acCmdRemoveFilterSort
Now the bit that dosn't work
Screen.ActiveForm.Filter = """ & Screen.ActiveControl.ControlSource & " Like " & Forms!frmfilterby.FilterFor & """
Screen.ActiveForm.FilterOn = True
or
Screen.ActiveForm.Filter = Screen.ActiveControl.ControlSource & " Like " & Forms!frmfilterby.FilterFor
Screen.ActiveForm.FilterOn = True
If I replace the Screen.ActiveControl.ControlSource with a form and control it works but I need to reference the current form and control not specific ones.
Help Please
I am trying to replicate the Filter By functionality on a custom popup (right click) toolbar. This is not specific to any form or any control on a form but allows a filter to be applied in any selected control.
I started by making the custom property load a filter criteria form called frmFilterBy.
The FilterBy form has a single unbound control named FilterFor.
The FilterFor control has a On Lost Focus event that hides the form then runs the public function FilterBy2
The FilterBy2 Function reads:
Option Compare Database
Public strFilter01 As String
Public strFilter02 As String
Public strFilter03 As String
Public strFilter04 As String
Public strFilter05 As String
strFilter02 = Screen.ActiveControl.ControlSource
strFilter01 = Screen.ActiveForm.Name
strFilter03 = Screen.ActiveForm.Name & "." & Screen.ActiveControl.Name
strFilter04 = Forms!frmfilterby.FilterFor
MsgBox strFilter01 (02,03,04) (this is just for development checking purposes)
DoCmd.FindRecord [Forms]![frmfilterby]![FilterFor], acEntire, False, , False, acCurrent, (True This finds the first matching record)
strFilter05 = Screen.ActiveControl.ControlSource & " Like " & [Forms]![frmfilterby]![FilterFor]
MsgBox strFilter05 (Check)
DoCmd.RunCommand acCmdRemoveFilterSort
Now the bit that dosn't work
Screen.ActiveForm.Filter = """ & Screen.ActiveControl.ControlSource & " Like " & Forms!frmfilterby.FilterFor & """
Screen.ActiveForm.FilterOn = True
or
Screen.ActiveForm.Filter = Screen.ActiveControl.ControlSource & " Like " & Forms!frmfilterby.FilterFor
Screen.ActiveForm.FilterOn = True
If I replace the Screen.ActiveControl.ControlSource with a form and control it works but I need to reference the current form and control not specific ones.
Help Please