Outputting multiple files

davesmith202

Employee of Access World
Local time
Today, 00:12
Joined
Jul 20, 2001
Messages
522
I have some code that outputs a single file but I want to modify this so it outputs multiple files. Currently, my code is:

Code:
Private Sub cmdSave_Click()
    Dim strFile As String
    Dim strA As String

    strFile = "C:\Documents and Settings\Dave\Desktop\" & "A-Data" & DefaultID & "-" & Replace(Time, ":", "-") & ".csv"

    strA = A

    Open strFile For Output As #1
    Print #1, strA
    Close #1

End Sub

How do I modify that so that I can output 3 seperate files, one for strA. strB and strC, for field A, B and C respectively?

Thanks,

Dave
 
What are you actually trying to perform? and is 3 a static number or is it likely to change (both up and down)?
 
I have 3 memo fields and want to output 3 seperate text files with the contents of each memo field. It will always be the same memo fields. Currently, it works fine for just one of my memo fields but I want to expand it to 3.
 
Simply create three queries one for each field and repeat your code with slight name variations to describe the contents
 
Would this work?

Code:
Private Sub cmdSave_Click()
    Dim strFile As String
    Dim strA As String
    Dim strB As String
    Dim strB As String


    strA = A
    strB = B
    strC = C


    strFile = "C:\Documents and Settings\Dave\Desktop\" & "A-Data" & DefaultID & "-" & Replace(Time, ":", "-") & ".csv"
    Open strFile For Output As #1
    Print #1, strA
    Close #1

    strFile = "C:\Documents and Settings\Dave\Desktop\" & "B-Data" & DefaultID & "-" & Replace(Time, ":", "-") & ".csv"
    Open strFile For Output As #1
    Print #1, strB
    Close #1

    strFile = "C:\Documents and Settings\Dave\Desktop\" & "C-Data" & DefaultID & "-" & Replace(Time, ":", "-") & ".csv"
    Open strFile For Output As #1
    Print #1, strC
    Close #1

End Sub
 
If strA,B & C contain the memo details from each of the same fields then I do not see why not. However place a DoEvents between each process to allow one to finish before commencing the next.

David
 
Would I just add i=DoEvents between each section where i is an undeclared variable?
 
No just the word DoEvents

Code:
...
Close #1

DoEvents

Code:
strFile = "C:\Documents and Settings\Dave\Desktop\" & "B-Data" & DefaultID & "-" & Replace(Time, ":", "-") & ".csv"
...
 

Users who are viewing this thread

Back
Top Bottom