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 an array with the results of an Access query? 1

Status
Not open for further replies.

wadjssd

Technical User
Jan 24, 2002
31
0
0
GB
I've got an existing query which produces a simple recordset of unique values (all text strings) from a table.
I'm writing a VBA module and would like to be able to automatically populate an array with these unique values.
Is this possible?
If so, any help / pointers would be gratefully received.

Thanks
wadjssd

 
Here is how I would do it:

Code:
    Dim rst As DAO.Recordset
    
    Dim astrSuppliers() As String
    
    Dim i As Integer
    
    Set rst = CurrentDb.OpenRecordset("qrySuppliers")
    
    
    rst.MoveFirst
    i = 1
    
    Do Until rst.EOF
    
        ReDim Preserve astrSuppliers(i)
        astrSuppliers(i) = rst![Supplier]
    
        rst.MoveNext
        i = i + 1
    Loop
    
    rst.Close
    Set rst = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top