vba - Update Null Fields with SQL in MS Access -


i'm trying run sql commands in access vba update blank (null) fields in column value obtained combobox in form.

at moment i'm receiving

run time error '3061' few parameters. expected 1

but appears formed.

the code i'm using below. user passed string, e.g. - "joe bloggs".

public sub testsub(user string) dim db dao.database dim sqlstr string set db currentdb  sqlstr = "update ttable1 set field1 = [" & user & "] field1 null;"  db.execute sqlstr  end sub 

i think need have user 'string' in query using single quotes. also, have used set db = currentdb instead of using as

public sub testsub(user string) dim db dao.database dim sqlstr string set db = currentdb  sqlstr = "update ttable1 set field1 = '" & user & "' field1 null;"  db.execute sqlstr  end sub 

edit: @jarlh has mentioned agree, don't think square parentheses required


Comments