How do I refer to refer to a table to set field values via string with VBA in Access? -


i'm new vba , access, have understanding.

i can set field using

[field1] = now() 

what want save name of field string , use variable reference field. way can save different field names variable , have code act on field name happens stored.

from can find, proper way in situation is:

private sub ctlupdatebutton_click() dim varfield string     varfield = dlookup("[targeted field]", "[other table]")  cases.fields(varfield) = now() end sub 

this code breaks on reference cases.fields(varfield) , reports error 'run-time error '424' object required.

the record source form query based on cases table.

i'm not familiar enough i'm working know if sufficient explanation.

not sure you're trying varfield = dlookup("[targeted field]", "[other table]")

dlookup returns value of field in table there 1 row in table? if - code work in theory - if not, you;ll have specifiy criteria find correct row

the last issue can't use table name directly in code (in case "cases")

if want change underlying record in form, can modify if field name in query , hasn't been renamed.

simply use me(varfield) = now()