Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Thanked 0 Times in 0 Posts

    Docmd.OpenQueries - where to output result and how (Access2003)

    I am sujre it is easy...when you know how! :-)

    I use to run 12 compliance queries manually.
    Now I want to automate it.

    docmd.openquery "Check_Names"
    docmd.openquery "Check_DEPTIDs"
    docmd.openquery "Check_CountryCode"
    docmd.openquery "Check_Missing_Temps"

    Mostly these come up with NULL result.
    However sometimes some of these come with result.
    I need to write this result into somewhere.

    It can not be a table due to the difference in columns qty and names.

    So it might be a text file? I would like something better but can't think of anything.

    I found code

    Dim fs, f
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
    Set f = fs.CreateTextFile("c:test.txt", True)
    f.WriteLine ("Hello World!")
    Set f = Nothing
    Set fs = Nothing

    However I need to have this code wrapped around my queries so they run and IF one comes up not NULL - it outputs result into the file with query name becase query name consist of what compliance it was where error occured.

    Can you help, please?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Docmd.OpenQueries - where to output result and how (Access2003)

    Instead of using OpenQuery, take a look at DoCmd.TransferText or DoCmd.OutputTo. Both can export a query to a text file.

    See the Access VBA help, or TransferText Method and OutputTo Method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts