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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Detail" change to "Field0"

Status
Not open for further replies.

jack1080

Programmer
Jun 2, 2007
34
MY
I have a table with 3 tables, which is orderID, Detail and price.
I write a Query
SELECT * FROM [tbl];
in the result table it shows me orderID, Field0 and price(Notice Detail has changed to Field0)

How do I show Detail as it is without changing it to Field0?

Something to note:
1. I don't have right to change the table field name
2. I need to use asterick * since some columns will be added in future, and all of them need to be showed.

Thanks for the help.
 
In your query, add Detail to the query grid. Right click on the field name (Detail) and select properties. (Make sure the window says "Field Properties", Not "Query Properties). Type the word Detail in the Caption box. Close the window. Uncheck the Show button under Detail. Run your query. The field column heading will show Detail.

HAVE WHO EVER DESIGNED THE DATABASE TO REDO IT CORRECTLY!!! DETAIL IS OBVIOUSLY AN INTERNAL NAME.
 
Thanks, this method worked nicely, but actually I am creating this query using vba. How to do this in vba?
Followed is the code

====start of code===

private sub command1_click()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim strSQL As String
Dim strXTabQueryName As String
strXTabQueryName = "tempQuery"
Set db = CurrentDb
Set qd = db.QueryDefs(strXTabQueryName)
strSQL = "select * from [" & Me.lstTable & "]"
qd.SQL = strSQL
Set qd = Nothing
Set db = Nothing
Me.subform1.SourceObject = "Query." & strXTabQueryName
Me.subform1.Requery

end sub

====end of code===

Me.lstTable is a list of table name, and what the code does is, after clicking command1 button,
populate the subform1 with the table in datasheet view.
 
Generally, I would suggest to figure out SQL to build the query in the QBE and switch to SQL in the SQL view. This may help but I can't think of a way to change (alias) a column name and use the * without repeating the column.

Code:
strSQL = "select *, Field0 As Detail from [" & Me.lstTable & "]"

A previous post perhaps has the best advice...

HAVE WHO EVER DESIGNED THE DATABASE TO REDO IT CORRECTLY!!! DETAIL IS OBVIOUSLY AN INTERNAL NAME.
 
Maybe you could first rename the column using SQL -
ALTER TABLE TableName RENAME COLUMN Detail TO Descrition;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top