By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

Using VB in Access to shuffle a record set then copy it over to another..

P: 21
Here is my prediciment. I have a database with a form. It in the people can pick a main category, then sub category, then it shows a list of questions from that in a sub form. I am trying to find a way to shuffle the questions in the sub form whenever they rechose a new sub category

[Main Category]
[Sub Category]

[SubForm with questions from sub category]

I was trying to change a shuffle script that I have used before to work here but have spent 3 hours and came up blank..

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo30_AfterUpdate()
  2. Dim MyDB As Database, MyRS As Recordset, intNoOfRecords As Integer
  3. Dim intRandomRecordNumber
  4. Set MyDB = CurrentDb
  5. Set MyRS = MyDB.OpenRecordset("Questions", dbOpenDynaset)
  6. MyRS.MoveLast
  7. intNoOfRecords = MyRS.RecordCount
  8. intRandomRecordNumber = Int(Rnd * intNoOfRecords)
  9. MyRS.AbsolutePosition = intRandomRecordNumber
  11. ' Dim rs As Object
  12. 'Set rs = Me.Recordset.Clone
  13. 'myRS.MoveFirst
  14. 'RS.MoveFirst
  15. 'Do Until MyRS.EOF
  16. 'rs.Edit
  17. 'rs.Fields("Question") = MyRS.Fields("Question")
  18. 'rs.Fields("Answer1") = MyRS.Fields("Answer1")
  19. 'rs.Fields("Answer2") = MyRS.Fields("Answer2")
  20. 'rs.Fields("Answer3") = MyRS.Fields("Answer3")
  21. 'rs.Fields("Topic") = MyRS.Fields("Topic")
  22. 'rs.Fields("Section") = MyRS.Fields("Section")
  23. 'rs.Update
  24. 'rs.MoveNext
  25. 'MyRS.MoveNext
  26. 'Loop
  29.  rs.FindFirst "[Topic] = '" & Me![Combo30] & "'"
  30.  If Not rs.EOF Then Me.Bookmark = rs.Bookmark

The first part is the shuffling of the questions.....the second part I was trying to figure out how to copy the contents of MyRS which is shuffled over RS. The last part just displays what is selected....Maybe I am TOTALLY off here. Any help would be great
May 3 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.