dynamic field name in query

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
 
R

Rob Wills

write your SQL in VBA using queryDef

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

HTH's
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top