i stared using microsoft access , i'm trying display query in form depending on written in textbox , open query double clicking row or cell filtered.
for example have table named customers list of customers , i'm trying find customer name of (for example) jhon writing "jhon" in textbox , double clicking on cell or row open row (using query).
table name "customers", form name "form2", subform (what i'm trying sort/filter) name "custormers subform1", name of unbound textbox "search".
here form looks : http://imgur.com/a/dpq7p.
thank help.
you can trigger search in afterupdate event handler of textbox , set filter property of subform
private sub search_afterupdate() dim s string s = "'" & replace(me!search.text, "'", "''") & "'" me![custormers subform1].form.filter = "firstname=" & s & " or " lastname=" & s end sub
make sure escape single apostrophs double ones. can search beginning of name with
s = " '" & replace(me!search.text, "'", "''") & "*'" me![custormers subform1].form.filter = "firstname" & s & " or " lastname" & s
the resulting filter looks (assuming user typed "jh")
firstname 'jh*' or lastname 'jh*'
Comments
Post a Comment