outputTo with variable outpput name 
Author Message
 outputTo with variable outpput name

Perhaps  a very simple trick for this, but as an absolute VBA newbie I
can't figure this one out.

I want to export the results of a Query in MSAccess as a txt file using
the outputTo command.
This procedure will run approx. 500 times so I'm trying to generate
their filename using a field-value from a different table (which has a
different value for each run of course) but I have absolutely no idea
how to do this...

Any help would be appreciated as it appears I'm totally stuck on this
one.

Kind regards,
Wicliff



Fri, 14 Jan 2005 20:06:44 GMT  
 outputTo with variable outpput name
Without any code for a starting point this is difficult to answer.  How are you
determining which record in the table to use for the file title - is there some
relationship between the records in the table and the query that is being
exported?
Quote:

> Perhaps  a very simple trick for this, but as an absolute VBA newbie I
> can't figure this one out.

> I want to export the results of a Query in MSAccess as a txt file using
> the outputTo command.
> This procedure will run approx. 500 times so I'm trying to generate
> their filename using a field-value from a different table (which has a
> different value for each run of course) but I have absolutely no idea
> how to do this...

> Any help would be appreciated as it appears I'm totally stuck on this
> one.

> Kind regards,
> Wicliff



Sun, 16 Jan 2005 03:59:49 GMT  
 outputTo with variable outpput name
okay here's the code (I'm sure you pro's think it's a mess, but hey, it works ;-):

Public Function SubsectieTicket()
    Do
        SubSectieCopy
        TicketMaken
        naamCopy
    Loop
End Function

    Sub SubSectieCopy()
        DoCmd.OpenTable "Subsectie names"   ' a table with approx 500 rows with
different values
        DoCmd.GoToRecord acDataTable, "Subsectie names", acNext, 1    ' selects
the next value
        RunCommand acCmdCopy
        DoCmd.OpenTable "ActieveSubSection" ' opens a new table with only one row
and one column
    On Error GoTo plakkuh
        RunCommand acCmdDeleteRecord
plakkuh:
        RunCommand acCmdPaste
        DoCmd.Close acTable, "ActieveSubSection"
    End Sub

Sub TicketMaken()
    DoCmd.OpenQuery "groupedcomments"
    RunCommand acCmdSelectAllRecords
    RunCommand acCmdCopy
    DoCmd.SetWarnings False
    DoCmd.Close
    DoCmd.RunMacro "flipflap"
    DoCmd.Close
    DoCmd.SetWarnings True
    DoCmd.OpenQuery "03-huidige itemgroupinvullen"
    DoCmd.OpenQuery "commentsvullen"
End Sub

Sub naamCopy()
   DoCmd.OutputTo acOutputQuery, "jobticket", acFormatTXT, ?????????, false
End Sub

where the value of the first record of the table "ActieveSubSection" (used in the
first sub (SubSectieCopy()) defines the filename (at least that's what I'm trying
to). there is no further relation to the query being exported. (called "jobticket"
used in the third sub)
The second sub (TicketMaken()) defines the content of the query used in the third
sub (naamCopy())

hope this makes it a little bit clearer what I'm trying to do

thanks in advance,
Wicliff

Quote:

> Without any code for a starting point this is difficult to answer.  How are you
> determining which record in the table to use for the file title - is there some
> relationship between the records in the table and the query that is being
> exported?


> > Perhaps  a very simple trick for this, but as an absolute VBA newbie I
> > can't figure this one out.

> > I want to export the results of a Query in MSAccess as a txt file using
> > the outputTo command.
> > This procedure will run approx. 500 times so I'm trying to generate
> > their filename using a field-value from a different table (which has a
> > different value for each run of course) but I have absolutely no idea
> > how to do this...

> > Any help would be appreciated as it appears I'm totally stuck on this
> > one.

> > Kind regards,
> > Wicliff



Fri, 21 Jan 2005 19:46:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I use contents of variable as field name(db!rst!variable)

2. converting an object variable (name of a file) into a string variable

3. The value of a variable (String type) is the name of a variable

4. building a string into a variable then text variable as a control name

5. Variable Name to Variable value.

6. variables naming variables

7. Get variable name from variable?

8. Variable values as variable names

9. naming a variable with a variable

10. Using variable to refer to variable name?

11. Automatic capitalization of variable names, type names, subs and functions

12. This array is fixed or temporarily locked Error with DoCmd.OutputTo

 

 
Powered by phpBB® Forum Software