473,395 Members | 1,996 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,395 software developers and data experts.

TransferText macro to export query to csv makes access hang!

ollyb303
Hi,

I am having a bit of a problem with TransferText macro.

I am using TransferText, Export Delimited (no field names) to export the results of a query as a .csv file.

The query is based on a linked table and uses a CDate([Nom_Date]) expression to convert the timestamp field (Nom_Date) from the table to a date type and the criteria:
Between (Now()-183) And Now() to narrow results to the last 6 months.

The query works just fine on its own and returns the expected results.

The macro, if run using the underlying table rather than the query, also works fine - it does take around 40 minutes (hence trying to trim the data down to the last 6 months!) but it does work.

When I run the macro using the query, it just hangs. Access stops responding, the status bar shows "Exporting" but never gets beyond 1 bar and task manager shows Access as not responding.
In fact it freezes my whole machine up, sometimes even stops updating the system time in the systray.

Access 2002 running on XP.

Does anyone have any idea why this might be.

Any help gratefully received.

Cheers,

Olly
Nov 4 '08 #1
7 5957
FishVal
2,653 Expert 2GB
Hello, Olly.

Do you try to export a huge amount of records?
If so, then have you tried to determine a maximum amount you could export without freezing computer?
It could be a good idea to export data in chunks and concatenate output files later.

Regards,
Fish
Nov 4 '08 #2
Thanks for replying Fish,

Yes, it is a lot of records, but when I am exporting ALL the data from the underlying linked table using the same macro (well, same apart from the table name), it does it. The .csv file generated is a big one (around 250Mb).

The query inludes only data from the last 6 months whereas the table includes data from the last 8 years, so I expect the number of records in the query to be (very roughly) 1/16 of the number in the table.

I wonder why my machine is happy to export 8 years of data, but refuses to export 6 months worth?
Nov 4 '08 #3
I have just had another thought with regard to this:

I am using the same method to export data from a different linked table in the same database; that is I am using a query which has the same:
Between (Now()-183) And Now() criteria for the date to narrow to the last 6 months.
The only difference is that with this query I am NOT using the CDate expression as the date in the table is in the correct format.
This table is actually bigger than the one I am having problems with, yet the macro runs no problem.

Could it be related to the CDate expression? I'm stumped TBH.

Thanks,

Olly
Nov 4 '08 #4
PianoMan64
374 Expert 256MB
I have just had another thought with regard to this:

I am using the same method to export data from a different linked table in the same database; that is I am using a query which has the same:
Between (Now()-183) And Now() criteria for the date to narrow to the last 6 months.
The only difference is that with this query I am NOT using the CDate expression as the date in the table is in the correct format.
This table is actually bigger than the one I am having problems with, yet the macro runs no problem.

Could it be related to the CDate expression? I'm stumped TBH.

Thanks,

Olly
Hello Olly,

One of the obvious problems that I'm seeing with your query is that with using the Now() function call as your set of criteria, your query is being updated (changed) every second. This in itself, would cause not only a lot of resources to be used, but will introduce unreliable results because one second, you may have one record that you thought should be included, and the next you won't. Not sure that using the Now() function is such a good idea. you may want to replace it with the Date Function, assuming that there isn't any time values that are associated with your date ranges?

as for the reason for the difference in performance issue, between exporting all the data, and exporting six months goes back to my previous explanation. Your query is most likely being updated every second, and it is causing your computer to really work at excatly what 6 months you want to export, since that changes every second.

Try changing the Now() function call with the Date() function call and see if you notice a change.

Let me know,

Joe P.
Nov 4 '08 #5
One of the obvious problems that I'm seeing with your query is that with using the Now() function call as your set of criteria, your query is being updated (changed) every second. This in itself, would cause not only a lot of resources to be used, but will introduce unreliable results because one second, you may have one record that you thought should be included, and the next you won't. Not sure that using the Now() function is such a good idea. you may want to replace it with the Date Function, assuming that there isn't any time values that are associated with your date ranges?

as for the reason for the difference in performance issue, between exporting all the data, and exporting six months goes back to my previous explanation. Your query is most likely being updated every second, and it is causing your computer to really work at excatly what 6 months you want to export, since that changes every second.

Try changing the Now() function call with the Date() function call and see if you notice a change.
As it happens, the Nom_Date field does include a time value as well, though this is not crucial to the query so I tried using the Date() function call instead and TBH I noticed absolutely no difference. The other macro/query I mentioned previously also includes a time value and I am using the Now() function call succesfully there, which compounds my belief that it may be related to the CDate expression.

Thanks for the reply,

Olly
Nov 4 '08 #6
FishVal
2,653 Expert 2GB
Hello, all.

@PianoMan64.
Though your guess is brilliant and I really like it, it is incorrect.
Access optimizes query execution by calculating expressions not dependant on record fields values only once.

@Olly.

It is really hard to find out a problem from what you've posted.
  • Post please more information.
    • Full SQL of the problematic query.
    • Metadata od table the query build on.
    • Code of export procedure
  • Try to localize error source by:
    • Applying different criteria in query.
    • Sequential removing of query fields.

Regards,
Fish
Nov 4 '08 #7
Fixed it.

Removed the CDate([Nom_Date]), replaced with just Nom_Date and used the criteria Between CDbl(Now()-183) And CDbl(Now())

Thanks for your help.
Nov 4 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: BigData | last post by:
I am attempting to create a delimited text file by using DoCmd.Transfertext as shown here. DoCmd.TransferText acExportDelim, "ExportSpec", "QryFinalExport", "Fileout.txt" This works fine as...
1
by: Trevor Best | last post by:
Just been having this problem when Exporting a query. DoCmd.TransferText acExportDelim, "GenMESR Export Specification", "qryGenMESRExport", Environ$("TEMP") & "\MESR.CSV", False I get the...
0
by: Kai Apel | last post by:
at last I always export a query with Docmd.TransferText,,qrn (Name of the Query), "c:\temp\text.txt" without any specification and MS Access use Tabstops for seperating. After reinstalling my...
3
by: Oliver Gabriel | last post by:
Hi, i want to export a table for later import, using vba. That´s my code: export: filename = "C:\HVOtabelle.txt"
6
by: Tim Marshall | last post by:
IN trying to export a Jet query (an actual saved Jet querydef which is written against a pass through query - not that that should be a problem) to text via either the File->Export... menu item or...
0
by: Sean Howard | last post by:
I have a strange problem linking tab delimited text files in Access 2000 (I am running Windows XP), please try this and let me know if I am going mad. Step 1. Create the tab-delimited text...
1
by: jschmidt | last post by:
Hello Everyone, Right now I have a macro set up to use a parameterized query with a transferText function. So when the user clicks on a button on the form they are prompted to enter a Stocking...
2
by: dogman_2000 | last post by:
Hi All I am using the docmd.transfertext to export my query as a .csv file. I am using an export spec which is seperated by a pipe. The problem I have is that I added an extra column onto the...
5
by: Dave | last post by:
Hello, I have a possible problem exporting a text field that happens to contain dates (but is not a date field) when using TransferText in MS Access 2000. I am exporting a query to a text...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.