variable in field name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to figure out if there is a way to enter a variable in a field name. for example - i have a query for a report with a field month (number) and other fields 1_temp, 2_temp. i'm trying to pull the value for the correct *_temp field based on the value the user enters for the month field. thanks for your time.
 
i'm trying to figure out if there is a way to enter a variable in a field name. for example - i have a query for a report with a field month (number) and other fields 1_temp, 2_temp. i'm trying to pull the value for the correct *_temp field based on the value the user enters for the month field. thanks for your time.

This is difficult *because you are improperly storing data in
fieldnames*. Data should be stored *in a field in the table*, not in a
fieldname!

To do what you ask you would have to write VBA code to actually build
the query SQL from scratch. Consider restructuring your tables so that
you have a MonthNo field with twelve records for the year, rather than
a wide-flat design with a one to many relationship embedded in each
record.
 
Back
Top