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

Outputting Data to Excel 1

Status
Not open for further replies.

bxgti4x4

Technical User
Feb 22, 2002
167
GB
I have a form with a sub form which displays cargo tank details for a particular vessel. The main form has an unbound text box which is used to select the vessel name, based on a table (TblVesselDetails) and the sub form displays a series of records, each of which contains details for one cargo tank for that vessel, based on a table (TblCT_Partic). The two tables are linked by means of a query (QryCTPartic) using the field “Vessel”.

On the main form is a Command Button which uses the “OutputTo” method to export the data from TblCT_Partic to Excel. The Excel data is then copied into an Excel Spreadsheet which is sent to operators in the field for updating. At present, the OutputTo method runs a second query (QryCTP) which is a copy of QryCTPartic but requires the vessel name to be specified. (“[Enter Vessel]”).

What I would like the Command Button to do is to run QryCTPartic and automatically select the vessel name, rather than prompting me for it.

The current code for the Command Button is:
Code:
DoCmd.OutputTo acOutputQuery, "QryCTP", acFormatXLS, "CTP.xls", True
Any help would be much appreciated.

Best Regards
John
 
you would have to edit your query to look at the form, in the fields which displays the vessel name.

In your query builder, find the field vessel, in the criteria line under the field you would need to write something like

[forms]![NAME OF FORM]![VESSEL FIELD NAME]

This will now run the query for only the vessel that is dispalyed on the form.

I hope this helps, and issue let me know
 
Thanks M8KWR, that solved the problem. Your prompt response is much approeciated.

Best Regards
John

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top