?
Solved

How To: Run TransferText Method on SQL string (instead of actual query)

Posted on 2005-04-19
5
Medium Priority
?
373 Views
Last Modified: 2008-02-01
Hello ~

I would like to run the following TransferText command on an SQL string, which I know works (I can execute the SQL string).

    DoCmd.TransferText acExportDelim, , "qryJournalMailing1", "c:\JournalSubs1.txt", True


When I replace "qryJournalMailing1" with my SQL string:

Dim db As Database
Dim strSQL1 As String

Set db = CurrentDb()

    strSQL1 = "SELECT......."
   
    DoCmd.TransferText acExportDelim, , "strSQL1", "c:\JournalSubs1.txt", True

I suspect "strSQL1" has to be something other than a string.....

Syntax ideas????

 
0
Comment
Question by:Chi Is Current
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:kmslogic
ID: 13819595
Hi jacobbarnett,

It has to be a query or a table.  You can create a query from your strSQL1 string and then refer to that query in the TransferText command.

Kelly
0
 
LVL 16

Accepted Solution

by:
kmslogic earned 2000 total points
ID: 13819631
jacobbarnett,

BTW, to create a query you'll do something like this:

    Dim strSQL As String
    Dim qrySQL As QueryDef
    strSQL = "SELECT * From MyTable"
   
    Set qrySQL = CurrentDb.CreateQueryDef("tmp_Query", strSQL)
    CurrentDb.QueryDefs.Append qrySQL
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 13819635
Thanks Kelly

Hmmmm.  I can create the query and refer to it alright....  'Thought it might be more compact to do it right in the module...

Any way to run the TransferText command on the SQL string as an object???
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 13819665
I see what you're saying now w/ QueryDef....  'will try this.

Thanks
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 13819768
OK.  'Seems like I might as well just run the TransferText command on an existing query and leave it at that.  I think it will be OK.  Thank you for the idea & the lesson!

Best Regards, Jacob
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

749 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