Hope this helps, add a command button named command1 and listbox named list1, insert the following code (you will have to make some minor adjustments, namely the path to your database, the field you are trying to retrieve, and the table name that the field is located in)....
Let me know if you get it to work for you! Good Luck!Code:Option Explicit
Private Sub Command1_Click()
Dim sArray()
Dim iRecCt As Long
Dim sSQL As String
Dim db As Database
Dim rst As Recordset
Set db = DBEngine.OpenDatabase("C:\strings.mdb")
'retrieve all the values from the Name field in the table named tblNames
' customize this to fit your database
sSQL = "SELECT Name From tblNames;"
Set rst = db.OpenRecordset(sSQL, dbOpenSnapshot)
' only proceed if records where returned
If Not rst.RecordCount = 0 Then
rst.MoveFirst
While Not rst.EOF
' change the dimensions of the array and preserve the values
ReDim Preserve sArray(iRecCt)
' load the current value in the recordset into the array
sArray(iRecCt) = rst!Name
iRecCt = iRecCt + 1
rst.MoveNext
Wend
End If
rst.Close
Set rst = Nothing
ShuffleArray sArray, 500
List1.Clear
For iRecCt = LBound(sArray) To UBound(sArray)
List1.AddItem sArray(iRecCt)
Next iRecCt
db.Close
Set db = Nothing
End Sub
Private Sub ShuffleArray(arr(), ByVal iShuffleTimes As Integer)
Dim iCt As Integer
Dim iRandElem As Integer
Dim vTemp
'assure we don't get the same set of random numbers
Randomize
For iCt = 1 To iShuffleTimes
iRandElem = (Rnd * (UBound(arr) - LBound(arr))) + LBound(arr) ' get an element within the bounds of the array randomly
vTemp = arr(LBound(arr)) ' assign the value of the first element in the array to the temporary variable
arr(LBound(arr)) = arr(iRandElem) ' shuffle the values
arr(iRandElem) = vTemp
Next iCt
End Sub
