Export to excel - Simple?

DAW

Registered User.
Local time
Yesterday, 19:45
Joined
Mar 22, 2006
Messages
70
I have used this loads of times before but not with a subform on a report. My code says:

Code:
DoCmd.OutputTo acOutputForm, "frmDetail", acFormatXLS, , True

where frmDetail is the subform on frm_Main (but not linked to frm_Main - i.e. for display only). So then I try:

Code:
DoCmd.OutputTo acOutputForm, "Form_frm_Main.frmDetail", acFormatXLS, , True

In both cases I get 'form is misspelled or refers to a form that doesn't exist'. What am I doing wrong :confused:
 
Why not use

docmd.transferspreadsheet etc.?
 
'cos it gives the same error. Besides, that way is a bit more restrictive.
 
Assuming arguendo that you can do what you're attempting, you're not referencing the subform correctly:

The subform is referenced:

Forms!frm_Main!frmDetail.form
 
Now that looks more like it! I was referencing the subform incorrectly as you suggest. Thanks for your help.
 
i am trying to do the same job and using essentially the same code, here is my statement

DoCmd.OutputTo acOutputForm, "Me![QRY_GetDupes subform].Form", acFormatXLS, , True

i am getting the same error as DAW got initially but i am referencing the subform in the way suggested by llkhoutx suggested - am i not?

elsewhere in my code this form of referencing works fine for example the following

Me![QRY_GetDupes subform].Form.RecordSource = strFilterSQL
Me![QRY_GetDupes subform].Form.Requery
Me![QRY_GetDupes subform].Form.Visible = True

is executed as the query i try and export is run just before the command button click function which contains the first statement above

i'd imagine i am referencing the subform incorrectly but numerous posts on this board have led me to that format and also this

http://www.mvps.org/access/forms/frm0031.htm

very useful reference

i'd be very grateful if anyone can guess what i'm doing wrong
 
You're creating a text string out of the form reference, as DAW did in this thread. Read my earlier posit in this thread.
 
Garethl next time, please start a new thread and reference this post in it.

Your problem is that "Me" is an object that points to the current form that has focus. It is not to be passed as an identifier, but only used in VB scripting; therefore when passed as a string parameter, the function is looking for a form or object that actually called "Me", which doesn't exist - you must use the literal object name and type identifier. You will need to use the format that Ilkhoutx suggested.

Example:
Forms![Main Form Name]![Subform Name].form
 

Users who are viewing this thread

Back
Top Bottom