Changing FieldName in a Query

G

Guest

I want to run a query 20 times, but change one fieldname each time. For
example:

#1 query - Select Vendor, T1 from tbl_Vendor where TI = true
#2 query - Select Vendor, T2 from tbl_Vendor where T2 = true
#3, #4, etc.

Is there any way I can change the selected field (T1, T2, etc) without
coding 20 queries. I am using design view to create the queries.

Thanks for any help.
 
J

JohnFol

Have 20 separate queries!

Serously though, this is not that complex a piece of code. How are you
opening the queries at the moment? If you are using VBA then simply perform
a loop and concatenate the T name, ie (untested)

For TNumber = 1 to 20
mySQL = "Select Vendor, T" & TNumber & " from tbl_Vendor where T" &
TNumber & " = true
:
next TNumber
 
G

Guest

John, Thank you so much. I am not a VBA coder. I have written some simple
SQL queries in my life, and now with your help I can simplify what I need to
do. I don't actually run all 20 queries, but have them in a macro with
conditional statements based on which Tcode I need to test against. I was
using the design view of a query and could not get it to accept any value
stored in a field to change the field name. I will certainly try it this way.
 

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

Similar Threads


Top