Link to home
Start Free TrialLog in
Avatar of robinski
robinski

asked on

Naming an output file

I am attempting to output club records from an Access database to an XLS format on a 'per club' basis using a command button and a parameter query.

I can output the single club file with this line:

DoCmd.OutputTo acQuery, "qryRollCall2XLS",
"MicrosoftExcelBiff8*.xls)", "E:\###\Database.xls", True, "", 0

using the parameter query.

I then attempted to make separate XLS files per club with this which is based on code I use to make RTF output from a report.

DoCmd.OutputTo acQuery, "qryRollCall2XLS",
"MicrosoftExcelBiff8 *.xls)", "E:\###\"  "Database_ID" & Me![Club
Ident] & ".xls", True, "", 0

I have not adapted it correctly because the error message reports that it can't find the field [Club Ident].

The next task will be to learn about making the separate XLS files without the need to use the command button 60 times.

Robin Chapple
Avatar of ZenMasterrr
ZenMasterrr

try.....

DoCmd.OutputTo acQuery, "qryRollCall2XLS",
"MicrosoftExcelBiff8 *.xls)", "E:\###\" & "Database_ID" & Me![Club
Ident] & ".xls", True, "", 0
ASKER CERTIFIED SOLUTION
Avatar of ZenMasterrr
ZenMasterrr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
..oh you need to create another query......qryRollCall3XLS
If MyRec.eof and Myrec.bof then
     I = Msgbox("NoRecords in tblClubs",vbokonly, "Error")
Else
MyRec.MoveFirst

For I = 0 to MyRec.recordcount -1
       MyDb.QueryDefs("qryRollCall3XLS").SQL = "SELECT * FROM qryRollCall2XLS WHERE ClubID ='" & MyRec!ClubID & "'"
       DoCmd.OutputTo acQuery, "qryRollCall3XLS","MicrosoftExcelBiff8 *.xls)", "E:\###\" & MyRec!DatabaseID & MyRec!ClubId & ".xls", True, "", 0
       MyRec.movenext
Loop
End If

hehe...having a blonde day
Avatar of robinski

ASKER

Zenmasterrr

Thanks for your help.

I am testing Item One first;

I notice a closing ) without an opening (

and in all the other pieces of code.

Is that confirmed?

Please also confirm that subsequent code is designed to produce the 60 files, in which case the points will be revised to 500 because I intended a separate question for that.

Robin