Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Naming an output file

Posted on 2004-10-13
7
Medium Priority
?
1,006 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

Technology Partners: 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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

618 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