?
Solved

Naming an output file

Posted on 2004-10-13
7
Medium Priority
?
1,002 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:robinski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12295435
try.....

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

Accepted Solution

by:
ZenMasterrr earned 1000 total points
ID: 12295498
to avoid the command button


create table with your clubs.... tblClubs

Function ExportClubs()

Dim I as Integer
Dim MyDB as Database
Dim MyRec as Recordset

Set MyDB = CurrentDB
Set MyRec = MyDB.OpenRecordset("SELECT DatabaseID, ClubIdent FROM tblClubs",dbopendynaset,dbreadonly)

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
End
End If
MyRec.close
MyDb.close
Set MyRec = Nothing
Set MyDB = Nothing

End Function


Zen :))


0
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12295500
..oh you need to create another query......qryRollCall3XLS
0
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12295508
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
0
 

Author Comment

by:robinski
ID: 12301150
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question