Datasheet Column Heading

D

David

Hello,

I posted to a thread yesterday, from 1/28/06. No response, so I am trying
here.

I am trying to change the column heading of certain columns in a form
opening in datasheet view. I am using a query as the data source for that
form.

Per the thread on 1/28, I learned I can use the "... fieldname AS
desiredfieldname FROM tablename (or queryname?).

I have the following syntax in my SQL statement, but get an error:

SYNTAX ERROR in the FROM CLAUSE.

I am trying to use data from another query, in this query, to get a column
name:

.... MasterCriteria.CriteriaValue1 AS CriteriaDesc1 FROM qryCriteriaHeadings...

Any ideas?

Thanks,
 
T

Tom Ellison

Dear David:

I believe the operative phrase in your post is:

"I am trying to use data from another query, in this query, to get a column
name"

Column aliases are made to fixed literal names, not to something variable.

You could get the column name in VBA and build the query from that.

Tom Ellison
 
T

Tom Ellison

Dear David:

More specific about "write VBA code and build the query"?

VBA code is what is placed in modules in Access. It is a form of Basic
Language programming.

Do you not know anything about this?

Public Function CreateQueryX(ColumnAlias As String)
CreateQueryX = "SELECT ColumnName AS " & ColumnAlias & " FROM YourTable"
End Function

You can save this and run it, or run it from code, or assign it as a
property of a control (RowSource) or a form (RecordSource).

Tom Ellison
 
D

David

Tom,

I guess I was asking for specificity about writing code to establish the
data source, vs. using a query as the data source.

Am I to understand that if I use code to establish the data source, I can
create variable column headings, whereas, if use a query, I cannot?

Again, I am using a query currently, and use the syntax in the query window
to try to establish the variable column heading name:
[qryCriteriaHeading]![CriteriaDesc1]: CriteriaValue1. The field
CriteriaDesc1 is what I want the column heading to be for CriteriaValue1.
 
Top