Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Access Table with Same number of records for each integer 1

Status
Not open for further replies.

rradelet

IS-IT--Management
Oct 28, 2003
35
0
0
CA
I have a simple Access 2000 table that contains one
numeric long integer field with 0 decimal places.

I am trying to populate the table so the count of the number of records for each integer between 1 and 500 is the same as that integer (1 row of 1, 2 rows of 2's, 3 rows of 3's etc):

Row 1 1
Row 2 2
Row 3 2
Row 4 3
Row 5 3
Row 6 3
Row 7 4
Row 8 4
Row 9 4
Row 10 4
Row 11 5
Row 12 5
Row 13 5
Row 14 5
Row 15 5
.
.
.
Row 125249 500
Row 125250 500


Can anyone help out with how this can be accomplished.

 
You can start with a table of numbers 0-9
[tt][blue]
tblNums0_9
[num]
0
1
2
3
4
5
6
7
8
9
[/blue][/tt]
Then create a query [qsel500]
Code:
SELECT [tblNum0_9]![Num]+[tblNum0_9_1].[Num]*10+[tblNum0_9_2].[Num]*100 AS B500
FROM tblNum0_9, tblNum0_9 AS tblNum0_9_1, tblNum0_9 AS tblNum0_9_2
WHERE ((([tblNum0_9]![Num]+[tblNum0_9_1].[Num]*10+[tblNum0_9_2].[Num]*100)<=500));
Then create another query to get your final values:
Code:
SELECT qsel500_1.Nums
FROM qsel500, qsel500 AS qsel500_1
WHERE (((qsel500.Nums) Between 1 And [qsel500_1].[Nums]) AND ((qsel500_1.Nums)>0));


Duane
Hook'D on Access
MS Access MVP
 
This first query works, but when I run the second query, I get "Enter Parameter Value" prompts:

1: qsel500_1.Nums

2: qsel500.Nums
 
You need to trouble-shoot my typos. Try the first query SQL of:
Code:
SELECT [tblNum0_9]![Num]+[tblNum0_9_1].[Num]*10+[tblNum0_9_2].[Num]*100 AS Nums
FROM tblNum0_9, tblNum0_9 AS tblNum0_9_1, tblNum0_9 AS tblNum0_9_2
WHERE ((([tblNum0_9]![Num]+[tblNum0_9_1].[Num]*10+[tblNum0_9_2].[Num]*100)<=500));

Duane
Hook'D on Access
MS Access MVP
 
It now works perfectly. Thanks so much. I am still kind of a novice with Access queries, so you have saved me hours of copying and pasting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top