473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping Issue with DoCmd.OutputTo

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. Next the user
can go into a Form which basically a dynamic query with a friendly
interface that eventually outputs a table that is stored in the DB as
well as exported to a CSV file. The CSV file is then used with a
vendor solution to fill in company information (prevents manual entry).

So in the code, I originally wrote a Do While Statement that stores all
the dynamic information that is used to generate a SQL Statement that
builds the table from the recordset. After the table is built and in
the Do While Statement, I have the following If Then Statement:

If strBuildCounter < strBuildRecords et Then
DoCmd.TransferT ext acExportDelim,, "Export_" & [strTable01],
"C:\My Data\" &
[strTable01] & ".csv", True
DoCmd.GoToRecor d , , acNext
Else
DoCmd.TransferT ext acExportDelim,, "Export_" &
[strTable01], "C:\My Data\" & [strTable01] & ".csv", True
End If

With this and the rest of the code in the event, the process works
great for building all the tables that are in the recordset. However,
after viewing the output in Excel, I learned that TransferText doesn't
keep the formatting that is in the table. After reading through some
of the articles here, I tried switching to using the following
DoCmd.Output line instead of the DoCmd.TransferT ext:

DoCmd.OutputTo acOutputTable, "Export_" & [strTable01], acFormatXLS,
"C:\My Data\" & [strTable01] & ".csv", False, ""

So the output that I get is exactly what I wanted from a formatting
perspective. However, for some reason now it is not building all of the
tables and CSV files. For example, if I have 6 records it will build
and export Table 1, Table 2, and Table 6. I am totally baffled because
the only thing that changed from is the DoCmd.TransferT ext line was
commented out and the new DoCmd.OutputTp line was added in the same
location in the If Then statement.

I threw in message boxes to see what the loop counter and total
recordset count were each time the loop ran through. For both the
DoCmd.TransferT ext and DoCmd.OutputTo line, it would say 1-6, 2-6, 3-6,
4-6, 5-6, and the 6-6. The one thing I did notice is that when I am
running the DoCmd.TransferT ext it is moving through the form records
fine. When I run the DoCmd.OutputTo, it will be on Form Record 1 and
make the Table 1. It will then advance to Form Record 2, make Table 2.
Then it will go back to Form Record 1 and remake Table 1. It will then
go to Form Record 2 again and remake Table 2. Then it will go back to
Form Record 1 and remake Table 1. Finally, it will go to Form Record 6
and make Table 6 and then be done.

If I had just done the DoCmd.OutputTo originally and never tried the
DoCmd.TransferT ext, I would assume the issue was in the looping code.
However, since it works with DoCmd.TransferT ext I am assuming that it
is something else that I am either doing wrong or a Microsoft issue.

I greatly appreciate any assistance on this.

Thanks!
Ryan

Aug 11 '06 #1
1 5307
Should be all set. Not sure what is causing the error but ended up
resolving it by adding a new section of code to the Do While statement.
Basically, I figure out what the name of the current record is,
FindFirst statement using the name of the current record, and then tell
it to MoveNext. What ends up happening is if I am on Form 4 it will go
to Form 1 and not run the process and then move to Form 5 and run the
process. Can't find anywhere in the code where it forces it to go to
Form 1 and why this only happens with DoCmd.OutputTo and not
DoCmd.TransferT ext. Oh well, at least it works now.

Thanks,
Ryan

Ryan wrote:
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. Next the user
can go into a Form which basically a dynamic query with a friendly
interface that eventually outputs a table that is stored in the DB as
well as exported to a CSV file. The CSV file is then used with a
vendor solution to fill in company information (prevents manual entry).

So in the code, I originally wrote a Do While Statement that stores all
the dynamic information that is used to generate a SQL Statement that
builds the table from the recordset. After the table is built and in
the Do While Statement, I have the following If Then Statement:

If strBuildCounter < strBuildRecords et Then
DoCmd.TransferT ext acExportDelim,, "Export_" & [strTable01],
"C:\My Data\" &
[strTable01] & ".csv", True
DoCmd.GoToRecor d , , acNext
Else
DoCmd.TransferT ext acExportDelim,, "Export_" &
[strTable01], "C:\My Data\" & [strTable01] & ".csv", True
End If

With this and the rest of the code in the event, the process works
great for building all the tables that are in the recordset. However,
after viewing the output in Excel, I learned that TransferText doesn't
keep the formatting that is in the table. After reading through some
of the articles here, I tried switching to using the following
DoCmd.Output line instead of the DoCmd.TransferT ext:

DoCmd.OutputTo acOutputTable, "Export_" & [strTable01], acFormatXLS,
"C:\My Data\" & [strTable01] & ".csv", False, ""

So the output that I get is exactly what I wanted from a formatting
perspective. However, for some reason now it is not building all of the
tables and CSV files. For example, if I have 6 records it will build
and export Table 1, Table 2, and Table 6. I am totally baffled because
the only thing that changed from is the DoCmd.TransferT ext line was
commented out and the new DoCmd.OutputTp line was added in the same
location in the If Then statement.

I threw in message boxes to see what the loop counter and total
recordset count were each time the loop ran through. For both the
DoCmd.TransferT ext and DoCmd.OutputTo line, it would say 1-6, 2-6, 3-6,
4-6, 5-6, and the 6-6. The one thing I did notice is that when I am
running the DoCmd.TransferT ext it is moving through the form records
fine. When I run the DoCmd.OutputTo, it will be on Form Record 1 and
make the Table 1. It will then advance to Form Record 2, make Table 2.
Then it will go back to Form Record 1 and remake Table 1. It will then
go to Form Record 2 again and remake Table 2. Then it will go back to
Form Record 1 and remake Table 1. Finally, it will go to Form Record 6
and make Table 6 and then be done.

If I had just done the DoCmd.OutputTo originally and never tried the
DoCmd.TransferT ext, I would assume the issue was in the looping code.
However, since it works with DoCmd.TransferT ext I am assuming that it
is something else that I am either doing wrong or a Microsoft issue.

I greatly appreciate any assistance on this.

Thanks!
Ryan
Aug 15 '06 #2

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

Similar topics

0
2254
by: Victor Kaiser | last post by:
I am using DoCmd.OutputTo to allow users to save Access reports in snapshot format or other desired formats. Once the user selects the desired format and clicks "OK", a dialog box appears that informs the user of the progress ("Now outputting page X of...to the file...") This is fine. However, the title of the dialog box is "Printing", which...
2
8035
by: deko | last post by:
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_" &...
0
3128
by: Frank Barnhart | last post by:
We have an application which runs Access under automation. With Access 97, the app included this line to send a report to a text file: myAccessObject.DoCmd.OutputTo acOutputReport, , acFormatTXT, "sample.txt" (The constant acOutputReport has the value of "MS-DOS Text (*.txt)". There is no object name in the command because the report is...
0
1586
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 produce Access hangs. That means, the file testreport.rtf is correctly created, but Access doesn´t quit. The process msaccess.exe stays and...
4
6262
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 non-roman characters that I can see) don't come through right. So he needs it in Unicode formatting. He's using code for the DoCmd.OutputTo command....
3
5477
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 made before actual printing. Need some way of calling Word as a mail merge with the information from an Access table that the current report uses. I...
1
6261
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 responding with the warning "File already exist". The file will be overwrite without any warning even with the DoCmd.Setwarnings True in
2
3745
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 DoCmd.OutputTo Macro action, but I can't seem to figure out how to run the macro automatically. I can succesfully run the macro below manually (without the...
16
4481
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 could be causing this. For example in the snippet below the docmd command brings up a box saying that it is outputting the file to c:\FullTimetable.snp...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.