Field Names from form in Query Field titles

samonwalkabout

Registered User.
Local time
Today, 11:35
Joined
Mar 14, 2003
Messages
185
I have a select Qry that im outputing into an excel file. I can name the field titles to better names ie.

2003 results: [x]*[Y]

Which is fine but i want to be able to show year name from another field in my form.
ie

=[year] & "results": [x]*[y]

i know you can do this in text boxes but i can seem to get it to work in a query field title.

Can it be done?

Many thanks
 
You need to refer to the control on the form. e.g. Forms!YourFormName!YourControlName. Put it in the criteria of the field concerned.

David
 
i dont want to filter the data in the colom just control the name thats displayed on the query field names.

So in the same way you can use
IE
whatevernameilike: actualfieldname

i want to use a value passed from a form in the whatevernamei like section.

IE

Whatevernameilike[fieldfromform]: actualfieldname

But im unsure of punctuation needed


=Whatevernameilike & [fieldfromform]: actualfieldname

="Whatevernameilike" & [fieldfromform]: actualfieldname

=("Whatevernameilike" & [fieldfromform]): actualfieldname

Just need to know correct format (if it is possible at all)
 
I don't think you can reference a form control in the query field name when building a query.

However, you can build an SQL statement in VBA and create a QueryDef (i.e. a saved query).  You can even use the Docmd.RunSQL method to run an SQL statement in VBA to export to Excel. Do a search for QueryDef, or Docmd.RunSQL Excel.
 

Users who are viewing this thread

Back
Top Bottom