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

Export a SQL View Directly from an ADP

Status
Not open for further replies.

RobLehman

Programmer
May 7, 2003
5
0
0
US
I have a view in SQL Server that I want to export to a file and/or e-mail as and Excel spreadsheet. I don't want to have to create a table or a report to accomplish this. Any ideas??
 
Robert,

With the view displayed on your monitor:

Select Tools / Office Links / Analyze It with MS Excel

Excel will open a workbook with the view'd records loaded.

From there you can format as desired.

To send the workbook out:

File / Send To / Mail Recipient

 
I should have been more clear...I mean how can I do it within VBA so that the user can just punch a button...
 
Include the following instruction with required parameters in event code under a button.

DoCmd.OutputTo objecttype[, objectname][, outputformat][, outputfile][, autostart][, templatefile]

The OutputTo method has the following arguments.

Argument Description

objecttype One of the following intrinsic constants:
acOutputDataAccessPage
acOutputForm
acOutputModule
acOutputQuery
acOutputReport
acOutputServerView
acOutputStoredProcedure
acOutputTable

objectname A string expression that's the valid name of an object of the type selected by the objecttype argument. If you want to output the active object, specify the object's type for the objecttype argument and leave this argument blank.
If you run Visual Basic code containing the OutputTo method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.

outputformat One of the following intrinsic constants:
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
If you leave this argument blank, Microsoft Access prompts you for the output format.

outputfile A string expression that's the full name, including the path, of the file you want to output the object to.
If you leave this argument blank, Microsoft Access prompts you for an output file name.

autostart Use True (–1) to start the appropriate Microsoft Windows–based application immediately, with the file specified by the outputfile argument loaded. Use False (0) if you don't want to start the application. This argument is ignored for Microsoft Internet Information Server (.htx, .idc) files and Microsoft ActiveX Server (*.asp) files.
If you leave this argument blank, the default (False) is assumed.

templatefile A string expression that's the full name, including the path, of the file you want to use as a template for an HTML, HTX, or ASP file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top