Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field value as field name in query

Status
Not open for further replies.

jw5107

Technical User
Jan 20, 2004
294
US
I am building a query in which I would like to use a field value from another table or a text box on a form and use that as the "new" field name in the query.

I have been working with:
[TblFleetType]![Fleet]: Fleet_3mRate - I keep getting error messages about puncuation and stuff.

I know you can use:
Fleet: Fleet_3mRate - But this is constant, I will need for it to change whenever the query is ran...

Any suggestions??
Thanks in advance!!
jw
 
You can only do that through VB. It the query itself, you can not do that.
 
hneal98,

Any examples as to how I can do this?
 
I have a question along these lines as well. I am using a calculated field to enter data into a query (products) based on product1 table. Calculated field:

FieldOne: "ProductX"

I run this query and save it however when i open the table the data is not present. However if I do a search and replace on the field with the same string ("some string") it shows up on the table.

I am new to databases and VB programming so I am not sure how things are linked excatly.

I would appreciate any assistance.

Thanks in advance,
Q
 
Now that I have re-read your request, I am not totally sure what it is you want. Can you rephrase your request? Does that value from the field exist as column in another table already?
 
Yes,

The value exist in a table that only has one field one record. So no criteria will be needed.

I need that value to appear as a field name in a query.
Like this: Fleet: Fleet_3mRate
The original name of the field is Fleet_3mRate. By adding Fleet: - when the query is ran, the field name is now Fleet.

I need for field name to be changed when the query is ran, but as the value of a field in a different table.

Hope this makes better sense??? Kinda hard to explain...
Thanks,
jw
 
It does, but still not sure why you want to do that. You would need to write code that would first run the query and then extract that piece and then finally set up another query based on another table (I am assuming.) that has that field name in it.

IF that is not what you are trying to do, then it does not make sense to me.

I don't have an example at this time. If I have time tonight I will try to see if I can gather one up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top