|
-
May 3rd, 2000, 01:54 AM
#1
Thread Starter
Member
Hi Everyone,
Is it possible, using the random option that accompanies VB6 to "shuffle" the records in a table, in Access?
If so, can you point me in the right direction?
Thanks!
-
May 3rd, 2000, 05:35 AM
#2
Thread Starter
Member
I need to pull the data out of a table, mix it up, and put it back into the same table.
Any pointers, tips, suggestions?
Thanks!
-
May 4th, 2000, 01:24 AM
#3
Frenzied Member
Use an array
I would not Post code without checking it, but can give you a general idea.
Define a User Type consisting of an Integer and a Single. Then Dim an array of Types.
Code:
Public Type ShuffleType 'Could be Private, I think'
RecordNumber As Integer
RandomNumber As Single
End Type
Dim ShuffleItem(1 to 500) as ShuffleType
Use Dim & ReDim if Array cannot have constant for Upper Bound.
Write a For-Loop which assigns integers 1 to Last to the integers, and which assigns a Random Number to the other variable.
Sort the array by the random number. Use the sorted array to assign new positions to the records.
I never used Access, but if it works like similar Products I have used, I suspect that you could get Access itself to do all the work. Put another field in each record to contain a Random Number. Assign Random Numbers to the new Field. Tell Access to sort by the field.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|