UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Split Table for Export.    
 
   
Berdy2Kristopher
post Aug 23 2004, 01:25 PM
Post #1

UtterAccess Enthusiast
Posts: 84
From: New Albany, Indiana, USA



I am looking for a way to split a table either before or during an export to a text file. If possible I would like Access to find the mid way point of the file based off a specific field. The field I would like to use is actually generated by a mailing verification software, so it might have a couple thousand entries that say "1" or "2". So in a 100,000 record table I might only have up to number "33" or so. Does anybody know where I would even start to try and accomplish this???

- A form Developer who got roped into Access and VB.
Go to the top of the page
 
+
truittb
post Aug 23 2004, 07:00 PM
Post #2

Retired Moderator
Posts: 13,544
From: Texas (Is there anywhere else?)



What is the value that will determine the midpoint? You say 1 or 2 or up to 33, I'm not sure what you mean.
Go to the top of the page
 
+
Berdy2Kristopher
post Aug 24 2004, 12:14 PM
Post #3

UtterAccess Enthusiast
Posts: 84
From: New Albany, Indiana, USA



I want the table split as close to in half as possible. I need to automate this split process to find the total number of "Trays" and split half the trays to one table and half to another. The trays must stay togather. So if a file has 31 trays out of 100,000 records I would like two tables to be generated, Table one would be tray 1 to 15 and Table two would be 16 to 31.

An example of a table I would want to split would be...
records 1 to 5,432 will have "1" in the tray field
records 5,433 to 9,012 will have "2" in the tray field
records 9,013 to 10,698 will have "3" in the tray field
records 10,699 to 15,641 will have "4" in the tray field

The first split table would have records 1 to 9,012 in it.
The second split table would have 9,013 to 15,461 in it.

The Trays need to be kept whole. I can have any number of Trays from 2 and up. The highest I usually deal with is around 600 trays.
Go to the top of the page
 
+
truittb
post Aug 24 2004, 06:37 PM
Post #4

Retired Moderator
Posts: 13,544
From: Texas (Is there anywhere else?)



Try this select query with a subquery. The subquery gets the max tray number does integer division "\" then uses the primary key as the criteria in the main query.

CODE
SELECT tblKeyWords.ID_PK, tblKeyWords.WordClusters, tblKeyWords.KeyWords, tblKeyWords.tRAY, DMax("tray","tblkeywords")\2 AS MidPoint
FROM tblKeyWords
GROUP BY tblKeyWords.ID_PK, tblKeyWords.WordClusters, tblKeyWords.KeyWords, tblKeyWords.tRAY, DMax("tray","tblkeywords")\2
HAVING (((tblKeyWords.ID_PK) In (SELECT tblKeyWords.ID_PK
FROM tblKeyWords
WHERE (((tblKeyWords.tRAY)<=DMax("tray","tblkeywords")\2));)));


Convert it to a make table query and to get the other half change in In () criteria to Not In ()
Go to the top of the page
 
+
truittb
post Aug 24 2004, 08:19 PM
Post #5

Retired Moderator
Posts: 13,544
From: Texas (Is there anywhere else?)



I reread your post and saw where you were exporting to a text file, so you don't need to convert to a make table query. Just use the SELECT statements.
Go to the top of the page
 
+
Berdy2Kristopher
post Sep 9 2004, 10:08 AM
Post #6

UtterAccess Enthusiast
Posts: 84
From: New Albany, Indiana, USA



Thank you very much. Everything worked perfect.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th May 2013 - 12:44 PM