macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is ther any macro (or other way) to choose randomly from specified fields/table
 
is ther any macro (or other way) to choose randomly from specified fields/table

Yes; a Query.

For a more detailed answer please post a more detailed question.
What's in your table? What result do you want?

John W. Vinson[MVP]
 
I have a table of let say 100 questions (text fields) , I need to randomly
choose and display ten questions on a report.
I don't know, I think that's enough.
Thank you
 
fuad said:
I have a table of let say 100 questions (text fields) , I need to randomly
choose and display ten questions on a report.
I don't know, I think that's enough.

Create a new Module named basRand and paste this little function into it:

Public Function RandNum(vIgnore As Variant) As Double
Static bDone As Boolean
If Not bDone Then
Randomize
bDone = True
End If
RandNum = Rnd()
End Function

Then create a Query based on your table of questions; in a vacant Field cell
type

SortKey: RandNum([QuestionNo])

using any fieldname in your table as an argument - this just forces Access
to call the function for every row instead of "saving time" by calling it
just once.

Sort ascending (or descending, makes no difference) by this field and set
the Query's Top Values property to 10.

John W. Vinson/MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top