dynamic field name in query

  • Thread starter Thread starter judith
  • Start date Start date
J

judith

I am setting a field in a query

P1: IIf([month]=1,[200001],0)

but I want the field name [200001] to be dynamically set from a field on
a form

Forms![frm999SystemForm]![updateField] e.g. 200001, 200002,

I think I might be looking for something like

fields(Forms![frm999SystemForm]![updateField] )

My idea is that i will run some VBA looping through a set of values which
will reset the form field and then re run the query for each value.

Any ideas please
 
write your SQL in VBA using queryDef

currentdb.querydefs("QUERY_NAME").sql = "SELECT " &
Forms![frm999SystemForm]![updateField] & " FROM TABLE_NAME"

HTH's
Rob
 
Back
Top