473,378 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DoCmd.OutputTo acOuputQuery -- Eats Query! Where did all my SQL go?

This code is behind a button that exports the contents of a query
("qryXL_Tx") to an Excel spreadsheet. It works fine the first time, but
will not run a second time. When I go to look at my query... it's blank!
No SQL at all....

Any ideas why this sub is eating my query??

Private Sub cmdExportXL_Click()
strXLfile = "Transactions_" & strTxType & strTxAcct & strQtr & strYr &
".xls"
DoCmd.OutputTo acOutputQuery, "qryXL_Tx", acFormatXLS, strXLfile, False
MsgBox "Excel file saved as:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) &
strXLfile, vbInformation, " Export To Excel Complete"
End Sub

many thanks...
Nov 12 '05 #1
2 8013
I think the problem occurs only when the query does not return any records.
The following code appears to be an effective remedy, but still testing...

If DCount("Entity_ID", "qryXL_Tx") = 0 Then Exit Sub

"deko" <dj****@hotmail.com> wrote in message
news:no********************@newssvr21.news.prodigy .com...
This code is behind a button that exports the contents of a query
("qryXL_Tx") to an Excel spreadsheet. It works fine the first time, but
will not run a second time. When I go to look at my query... it's blank!
No SQL at all....

Any ideas why this sub is eating my query??

Private Sub cmdExportXL_Click()
strXLfile = "Transactions_" & strTxType & strTxAcct & strQtr & strYr &
".xls"
DoCmd.OutputTo acOutputQuery, "qryXL_Tx", acFormatXLS, strXLfile, False
MsgBox "Excel file saved as:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) &
strXLfile, vbInformation, " Export To Excel Complete"
End Sub

many thanks...

Nov 12 '05 #2
The problem persisted, so I resorted to a make table query:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryXL_Tx" '<=== make table query
DoCmd.SetWarnings True
If DCount("Entity_ID", "tblXL_Tx") = 0 Then Exit Sub
DoCmd.OutputTo acOutputTable, "tblXL_Tx", acFormatXLS, strXLfile

"deko" <dj****@hotmail.com> wrote in message
news:L7*****************@newssvr27.news.prodigy.co m...
I think the problem occurs only when the query does not return any records. The following code appears to be an effective remedy, but still testing...

If DCount("Entity_ID", "qryXL_Tx") = 0 Then Exit Sub

"deko" <dj****@hotmail.com> wrote in message
news:no********************@newssvr21.news.prodigy .com...
This code is behind a button that exports the contents of a query
("qryXL_Tx") to an Excel spreadsheet. It works fine the first time, but
will not run a second time. When I go to look at my query... it's blank! No SQL at all....

Any ideas why this sub is eating my query??

Private Sub cmdExportXL_Click()
strXLfile = "Transactions_" & strTxType & strTxAcct & strQtr & strYr &
".xls"
DoCmd.OutputTo acOutputQuery, "qryXL_Tx", acFormatXLS, strXLfile, False
MsgBox "Excel file saved as:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) &
strXLfile, vbInformation, " Export To Excel Complete"
End Sub

many thanks...


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Randy King | last post by:
Newbie here, so please bear with me. I have a module that just hangs. I have tracked it down to this line in the genMappings() module: DoCmd.OutputTo acQuery, "Mappings", acFormatXLS, _...
0
by: Robert Langen | last post by:
I'm calling an Access XP application from an Outlook XP appointment form. Everything works, but the lines DoCmd.OutputTo acOutputReport, "testreport", acFormatRTF, "c:\test.rtf", False Docmd.Quit...
4
by: tmountjr | last post by:
I've got a user who's trying to export a text file with unicode formatting. When he exports it as straight ascii, some of the foreign characters (mostly just accent marks and the like - no...
2
by: Vincent | last post by:
I am building an SQL string in a subroutine and was wondering if this could be passed directly to the docmd.outputto method as the source of the output I wish to generate. It does not appear you...
1
by: Ryan | last post by:
Hello. I was hoping that someone may be able to assist with an issue that I am experiencing. I have created an Access DB which imports an Excel File with a particular layout and field naming. ...
3
by: ljungers | last post by:
I need to make some changes to a Query/select/print report using word application. What I need to do is change the way Word is called yet keep the process the same. Word is used so changes can be...
1
by: Simon | last post by:
Dear reader, With the DoCmd.OutputTo ...... you have the possibility to write a report to an external location. In case the external location is an existing file the DoCmd is not...
2
by: jmartmem | last post by:
Greetings, I have several Access 2007 reports that I regularly export to individual PDF flat files on a web server. I've successfuly created a module sub to export the reports using the...
16
by: g diddy | last post by:
Hi, I have used the Docmd.outputto function in various places in my code but for some reason all code that comes afterwards, even msgbox doesn't show. I was just wondering if there is anything that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.