How can I retrieve the underlying field definition given the alias?

M

Max Moor

Hi All,
I have a field list taken from a query. I want to use it to build a
"sub-query" in code. Everything works, as long as none of the field names
are aliases. Of course, some are. For example, I have a field defined in
the query as:

tblContacts.LastName & ", " & tblContacts.FirstName AS UserName


When the sub-query runs, it complains that it doesn't know about
"UserName". Of course, the SELECT clase wants the whole thing. The
OrderBy clause wants just the first part, without the alias.

So... Is there some relatively simple VB code that will return the
field's definition (tblContacts.LastName & ", " & tblContacts.FirstName),
given its alias name (UserName)?

I really hate the thought of having to parse the base query's SQL
statement myself.

Thanks, Max
 
Top