Access VBA SQL Statement with LIKE & AND -


i trying call access query(qry_timecardstatus) form has 3 fields: weekending date, supplier name, , status type (list box multi-select).

because mult. select list box criteria needs created in vba found code works great!

 set db = currentdb()  set q = db.querydefs("qry_timecardstatus")  q.sql = "select * data [approval status] in(" & criteria & ");" 

however, need add other 2 field criteria on code above. when manually inputting sql sql view in access, additional 2 criteria sql statements work like:

like "*" & [forms]![frm_timecardstatus]![suppliercb] & "*" "*" & [forms]![frm_timecardstatus]![startdatetxt] & "*" 

can please construct vba necessary account 3 form fields , execute query named (qry_timecardstatus)?

why need call defined query if try build new 1 - choose 1 or other:

the following should work: combines 3 statments and (you use or too, not sure, need) , wraps in ". need specify 2 fields want filter though.

set db = currentdb() dim rs recordset set rs = db.openrecordset "select * data [approval status] in(" & criteria & ") , " & _         "[otherfield] ""*" & [forms]![frm_timecardstatus]![suppliercb] & "*"" , " & _         "[anotherfield] ""*" & [forms]![frm_timecardstatus]![startdatetxt] & "*""" 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -