access vba - .findfirst vba access2010 unbound form runtime error -
i have following vba code populate unbound fields in unbound form in access 2010 :
private sub combo0_afterupdate() dim d database dim rsexp recordset dim criteria string set d = currentdb set rsexp = d.openrecordset("expasset", db_open_dynaset) criteria = "[serial_number]=" & [combo0] rsexp.findfirst criteria me!name = rsexp("user") me!type = rsexp("type") me!model = rsexp("model") me!notes = rsexp("notes") me!department = rsexp("department") me!status = rsexp("status") rsexp.close end sub
i getting error on line rsexp.findfirst criteria runtime error 3077 syntax error (missing operator) in expression.
i have changed code criteria = "[serial_number]=" & str([combo0]) runtime error 13 type mismatch.
give opportunity examine criteria you're asking .findfirst
use. may not expect.
dim strcriteria string 'strcriteria = "[serial_number]=" & me.combo0 ' since serial_number text, enclose combo0 value in quotes ' when build strcriteria strcriteria = "[serial_number]='" & me.combo0 & "'" debug.print strcriteria ' or msgbox strcriteria if prefer
you can see output debug.print
in immediate window. go there ctrl+g
if [serial_number]
text data type, , debug.print
gives either of these, have problem.
[serial_number]=a0123 [serial_number]=
if doesn't lead solution tell data type of [serial_number]
, value of me.combo0
when encounter error.
Comments
Post a Comment