Using variables for query column headings

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

Guest

Using Access 2003
I want to be able to use varables to refer to query column headings so that
I can use user input to decide which columns appear on a report.
For example:
rstT is based on a table, rstQ on a query (crosstab)
I have found that:
rstT!Field1 = rstQ!assess1 'this works - assess1 is a column in the query)

But
Dim strField As String
strField = "assess1"
rstT!Field1 = rstQ!strField 'does not work (item not found in this
collection)

Is there a way to to make something like this work? I have tried various
combinations of [], " & & " etc
 
Thanks Steve - Works a treat
--
Tris


Steve Schapel said:
Tris,

Try like this...
rstQ(strField)

--
Steve Schapel, Microsoft Access MVP
Using Access 2003
I want to be able to use varables to refer to query column headings so that
I can use user input to decide which columns appear on a report.
For example:
rstT is based on a table, rstQ on a query (crosstab)
I have found that:
rstT!Field1 = rstQ!assess1 'this works - assess1 is a column in the query)

But
Dim strField As String
strField = "assess1"
rstT!Field1 = rstQ!strField 'does not work (item not found in this
collection)

Is there a way to to make something like this work? I have tried various
combinations of [], " & & " etc
 
Can you explain the whole procedure. I already got my crosstab query to
work. I just want to be able to to select a range (my column headers are
years) say from 2000 to 2009.
 

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

Back
Top