Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Question Unanswered: Randomize field data in VBA

    I am trying to randomize data in an access table that will be outputted to a form. I have 20 entries and need to randomize 10 that will then be shown one by one in a form using VB. Any help would be most appreciated.

  2. #2
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    I do something similar so I hope this helps.

    Firstly I create a copy of the table that holds the data (just structure).

    I add one new autonumber field to this table called Random and set its new values property to Random (if the table already has an autonumber field you will need to change it to number).

    This means any new data added will generate a randomly generated autonumber.

    I then create a query based on this table and order the records by the field Random and limit the return to 10 records.

    To use - set the forms recordsource to this query and on the forms on load property run an append query of the data from the original table to the random table.

    This should when the form opens show a random selection of the records restricted to 10 records.

    Just rember to delete the data in the Random table on exit ready for use next time.

    This should always randomly return 10 records from your 20.

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •