vba - Filter Subform, Starts With, Multiple criteria -


i filter subform based on data put text box. code below show record if student id typed perfectly. want have filter show records in student id, first name or last name starts me.sort.text

private sub sort_change() if isnull(me.sort.text) or me.sort.text = ""     me.students_subform.form.filteron = false else     me.students_subform.form.filteron = true     me.students_subform.form.filter = "[student id] ='" & me.sort.text & "'" end if end sub 

it sounds me need filter expression 3 like conditions or'd together.

for example if me.sort.text contains text "foo", build filter expression string such ...

 "[student id] 'foo*' or [first name] 'foo*' or [last name] 'foo*'" 

i tested code in access 2010 , filters subform think want ...

private sub sort_change()     dim strfilter string      me.sort         if len(.text & vbnullstring) > 0             strfilter = "[student id] '" & .text & _                 "*' or [first name] '" & .text & _                 "*' or [last name] '" & .text & "*'"         end if     end     debug.print "strfilter: " & strfilter '<- inspect in immediate window                                           ' ctrl+g take there     me.students_subform.form         if len(strfilter) = 0             .filteron = false         else             .filter = strfilter             .filteron = true         end if     end end sub 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -