K
Kay
I am running the following code on a button I select after updating a textbox
named "SearchBox".
..
Option Compare Database
'------------------------------------------------------------
' NVDR_Monthly_Report1
'
'------------------------------------------------------------
Function NVDR_Monthly_Report1()
On Error GoTo NVDR_Monthly_Report1_Err
If (Eval("[Forms]![NVDR MONTHLY REPORT]![SearchBox] Is Null")) Then
' Clear Filter when search box empty
DoCmd.RunCommand acCmdRemoveFilterSort
End
End If
' Handle "'s in search
TempVars.Add "strSearch", "Replace([Forms]![NVDR MONTHLY
REPORT]![SearchBox],"""""""","""""""""""")"
' Build the Filter
TempVars.Add "strFilter", """([Vin#] Like """"*"" &
[TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Stock
nUMBER] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([CUSTOMER
NAME] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([notes] Like
""""*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Employee id]
Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
DoCmd.ApplyFilter "", TempVars!strFilter
TempVars.Remove "strFilter"
TempVars.Remove "strSearch"
If (Eval("[Forms]![NVDR MONTHLY REPORT]![SearchBox] Is Not Null")) Then
DoCmd.SetProperty "CMDSHOWALL", acPropertyEnabled, "-1"
End If
NVDR_Monthly_Report1_Exit:
Exit Function
NVDR_Monthly_Report1_Err:
MsgBox Error$
Resume NVDR_Monthly_Report1_Exit
End Function
What I would like to do is put it on the "OnChange" property of the
"SearchBox" so it filters as I type. When I try this, each keystroke it
stops and re-filters (like I want) but instead of allowing me to continue it
highlights the entry in the box so if I try to keep typing, it types over
what I already entered.
How do I continue typing in the box without haveing to use the mouse to put
the curser after the first keystroke? I hope I made sense and thanks in
advance for any help you can offer.
named "SearchBox".
..
Option Compare Database
'------------------------------------------------------------
' NVDR_Monthly_Report1
'
'------------------------------------------------------------
Function NVDR_Monthly_Report1()
On Error GoTo NVDR_Monthly_Report1_Err
If (Eval("[Forms]![NVDR MONTHLY REPORT]![SearchBox] Is Null")) Then
' Clear Filter when search box empty
DoCmd.RunCommand acCmdRemoveFilterSort
End
End If
' Handle "'s in search
TempVars.Add "strSearch", "Replace([Forms]![NVDR MONTHLY
REPORT]![SearchBox],"""""""","""""""""""")"
' Build the Filter
TempVars.Add "strFilter", """([Vin#] Like """"*"" &
[TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Stock
nUMBER] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([CUSTOMER
NAME] Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([notes] Like
""""*"" & [TempVars]![strSearch] & ""*"""")"""
TempVars.Add "strFilter", "[TempVars]![strFilter] & "" OR ([Employee id]
Like """"*"" & [TempVars]![strSearch] & ""*"""")"""
DoCmd.ApplyFilter "", TempVars!strFilter
TempVars.Remove "strFilter"
TempVars.Remove "strSearch"
If (Eval("[Forms]![NVDR MONTHLY REPORT]![SearchBox] Is Not Null")) Then
DoCmd.SetProperty "CMDSHOWALL", acPropertyEnabled, "-1"
End If
NVDR_Monthly_Report1_Exit:
Exit Function
NVDR_Monthly_Report1_Err:
MsgBox Error$
Resume NVDR_Monthly_Report1_Exit
End Function
What I would like to do is put it on the "OnChange" property of the
"SearchBox" so it filters as I type. When I try this, each keystroke it
stops and re-filters (like I want) but instead of allowing me to continue it
highlights the entry in the box so if I try to keep typing, it types over
what I already entered.
How do I continue typing in the box without haveing to use the mouse to put
the curser after the first keystroke? I hope I made sense and thanks in
advance for any help you can offer.