Smartgambler
Pro-Punter

Go Back   OZmium Sports Betting and Horse Racing Forums > Public Forums > Horse Race Betting Systems
User Name
Password
Register FAQ Search Today's Posts Mark all topics as read

To advertise on these
forums, e-mail us.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 6th March 2006, 12:37 PM
Duritz Duritz is offline
Member
 
Join Date: Dec 2004
Posts: 956
Default MS Access help

Hi all, need to extract large amounts of info from my database of results etc, heaps of records, as you know Aus racing prolific. So, here's my query:

I am using the export feature in Query in Access, to export a large quantity of info to a text file. Is there any way for Access to automatically break it up into smaller files instead of sending it to one large text file?

Preferably, I'd like it to be able to break it up into month by month files - there's three years worth of data (starting 2003) so it'd have a Jan 03, Feb 03 etc.

Is this possible, or is there any other way to get Access to export to a number of files, rather than just one?

Another way might be to limit it to say 5,000 records per text file perhaps?
Reply With Quote
  #2  
Old 6th March 2006, 04:23 PM
wesmip1 wesmip1 is offline
Member
 
Join Date: Sep 2005
Posts: 1,601
Default

Duritz,

You could pass a date range to the query and run it for any range you want.

Let me know if you need help.
Reply With Quote
  #3  
Old 6th March 2006, 06:33 PM
Duritz Duritz is offline
Member
 
Join Date: Dec 2004
Posts: 956
Default

And then I'd have to run the query 38 or so times, with a different file name each time for the result, right?
Reply With Quote
  #4  
Old 6th March 2006, 06:50 PM
wesmip1 wesmip1 is offline
Member
 
Join Date: Sep 2005
Posts: 1,601
Default

Duritz,

Yes and No.

Yes it has to be run 38 times. No you don't have to run it. You could write a macro that does it for you (including naming the file). It would probably take a couple of hours to write up and test.

Good Luck.
Reply With Quote
  #5  
Old 7th March 2006, 01:10 PM
Duritz Duritz is offline
Member
 
Join Date: Dec 2004
Posts: 956
Default

Thanks Wesmip.
Reply With Quote
  #6  
Old 10th March 2006, 07:45 PM
PunterPete PunterPete is offline
Member
 
Join Date: Jan 1970
Location: NSW
Posts: 53
Wink MS Access

Try this - Very simple text file creation.
Insert a button on a form and place the following code under "On Click":
Note I have written this very quickly and haven't tested it and you will need to insert your own query and make your own formula for d1 & d2.

Dim dbs As Database
Dim rst, horserst As Recordset
Dim strSQL, filename As String
Dim d1, d2 As Date
Dim i

For i = 1 To 38 ' or however many files you need

'd1 = Calculation to get lower date using i
'd2 = Calculation to get upper date using i

filename = "Info" & i & ".txt"
Open "C:\DIR\" & filename For Output As #1

Set dbs = CurrentDb
strSQL = "INSERT QUERY FOR ALL DATA HERE" ' eg "SELECT .....;"
Set rst = dbs.OpenRecordset(strSQL)

rst.MoveFirst
i = 0
Write #2, "COLTILE1"; "COLTITLE2"; "COLTITLE3"; et; etc

Do While Not rst.EOF
If rst.Fields(0) >= d1 And rst.Fields(0) <= d2 Then
Write #2, rst.Fields(0).Value;
Write #2, rst.Fields(1).Value;
Write #2, rst.Fields(2).Value;
Write #2, rst.Fields(3).Value;
Write #2, rst.Fields(4).Value;
Write #2, rst.Fields(5).Value;
'etc etc etc
End If
Loop
Close #2
rst.Close
Next i
__________________
Regards,
Pete
Reply With Quote
  #7  
Old 10th March 2006, 08:02 PM
marcus25 marcus25 is offline
Member
 
Join Date: Dec 2004
Posts: 172
Default

Quote:
Originally Posted by PunterPete
Set dbs = CurrentDb
strSQL = "INSERT QUERY FOR ALL DATA HERE" ' eg "SELECT .....;"
Set rst = dbs.OpenRecordset(strSQL)

Do While Not rst.EOF
If rst.Fields(0) >= d1 And rst.Fields(0) <= d2 Then
Write #2, rst.Fields(0).Value;
Write #2, rst.Fields(1).Value;
Write #2, rst.Fields(2).Value;
Write #2, rst.Fields(3).Value;
Write #2, rst.Fields(4).Value;
Write #2, rst.Fields(5).Value;
'etc etc etc
End If
Loop
Close #2
rst.Close

Hi!
"rst.Fields(0) >= d1 And rst.Fields(0) <= d2" this could go straight into strSQL like "where the date is >= and date is <= " the date in the database, saves you going through the loop. SQL is at least a hundred times faster than a loop, depending on a few other things of course.
(<= be careful how you define d1 and d2 I would use < d2 because you might double up on the upper date).
cheers

Last edited by marcus25 : 10th March 2006 at 08:21 PM.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump



All times are GMT +10. The time now is 07:51 PM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2008 OZmium Pty. Ltd. All rights reserved . ACN 091184655