Repost: Make table query

  • Thread starter Thread starter Angela
  • Start date Start date
A

Angela

I did not get a response on this, so am trying again.

Is this possible in a query?

I found a function at
http://www.mvps.org/access/queries/qry0011.htm that works
nicely to pull numbers at random from a table. In
addition I need to automatically fill in additional fields.

Example:

I have a set of 20 numbers in a table. The user specifies
the number of rows and columns eg. 4 rows, 5 columns.

I need to use the function to pull the 20 numbers at
random and automatically fill in the rows/columns eg.

Row Col Number
1 1 5934
1 2 9742
1 3 8733
1 4 7508
1 5 2275
2 1 1535
2 2 1789
2 3 5847
2 4 9087
2 5 2358
3 1 3980
....
4 5 9291

Angela
 
I did not get a response on this, so am trying again.

Is this possible in a query?

I found a function at
http://www.mvps.org/access/queries/qry0011.htm that works
nicely to pull numbers at random from a table. In
addition I need to automatically fill in additional fields.

Example:

I have a set of 20 numbers in a table. The user specifies
the number of rows and columns eg. 4 rows, 5 columns.

I need to use the function to pull the 20 numbers at
random and automatically fill in the rows/columns eg.

One way you could do this would be to use an auxiliary table. I'll
routinely have a table named Num with one long integer field N, filled
with numbers from 1 through 10000.

Create a Cartesian Join query by adding table NUM to the query grid
twice, with *no* join line.

The SQL would be something like

INSERT INTO targettable(Row, Col, Number)
SELECT Num.N, Num_1.N, 10000*RndNum(Num.N)
FROM Num, Num AS Num_1
WHERE Num.N <= [Enter number of rows:]
AND Num_1.N <= [Enter number of columns:];
 
Back
Top