exporting alias query column headings

datacontrol

Registered User.
Local time
Today, 17:45
Joined
Jul 16, 2003
Messages
142
I have an alias query set up, to get rid of generic field names. When I export the query to excel via Access or via VBA code, the alias field names are rest to the generic ones. Is there any way to retain the alias headings when exporting?

thanks.
 
Have you tried selecting each field in the design grid then rightclick and select properties and enter your headings in the Caption property?

Andy
 
I posted my sub routine and sql below. I used the caption property in my alias query to set headings.

SELECT test.Field1, test.Field2, test.Field3, test.Field4, test.Field5, test.Field6, test.Field7, test.Field8, test.Field9, test.Field10, test.Field11, test.Field12, test.Field13, test.Field14, test.Field15, test.Field16, test.Field17, test.Field18, test.Field19, test.Field20, test.Field21, test.Field22, test.Field23, test.Field24, test.Field25, test.Field26, test.Field27
FROM test;

_______________________________________________


Private Sub Command161_Click()
Dim strFilter As String
Dim strSaveFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)

'here you would probaly want your Transfertext code
'for example

DoCmd.TransferSpreadsheet acExport, 8, "test (dump) Without Matching after", strSaveFileName, True, ""

MsgBox "Your data has been saved", vbOKOnly
End Sub
 

Users who are viewing this thread

Back
Top Bottom