searchbox to filter form

james_halliwell

Registered User.
Local time
Today, 09:47
Joined
Feb 13, 2009
Messages
211
Please could someone point me in the right direction,
I have a form which i have put a text box in Called SearchBox and then i have a subform which is called Hip_Knee_Instruments_Subform i try the below maro to filter the subform on what is typed in the text box

SetTempVar strSearch, Replace([Forms]![Hip_Knee_Information]![SearchBox],"""","""""")

SetTempVar strFilter, "([Hospital_No_&_Name] Like ""*" & [TempVars]![strSearch] & "*"")"
SetTempVar strFilter, [TempVars]![strFilter] & " OR ([Instrument_Kit] Like ""*" & [TempVars]![strSearch] & "*"")"
ApplyFilter , =[TempVars]![strFilter],
RemoveTempVar strFilter
RemoveTempVar strSearch
SetProperty cmdShowAll, Enabled, 1

Please forgive me but very very new to this type of thing the code maybe rubbish but i am feeling i am close, i get an error message saying :-

The action or method is invalid because the form or report isn’t bound to a table or query

Use the select object action or method to select the desired form or report

Could some one point help me out have been working on this for sometime

Thanks
 
Hello James,

I would do that with VBA, so I cannot comment on the macro syntax, but by the error message I would think that the macro does not know what form the filter (the form or the subform).
Just do as the message says. Add a SelectObject Marcro action (giving the subform the focus) before the ApplyFilter.

HTH
Thomas
 

Users who are viewing this thread

Back
Top Bottom