Reorder records and reset indexing?

G

Guest

I don't know if it is possible but here is what I would like to do if
possible. I have a table with two fields: Week (number) and Word(text). The
week field can contain numbers from 1 to 10. An example might be:
1 current
1 correct
2 devise
2 disrupt
etc.
I have a randomize statement that randomizes the words based on the index
number of the week. So if I wanted to get the words from week 1 the randomize
statement would use the index number 1 as the max value. The problem is, if I
enter a new word for week one, it is index number 4 and I want it included in
the week one list of randomized numbers. Is it possible to resort the data on
the week field and then have Access re-index? If so, I would then want to
count how many records there were in week 1, 2, 3, 4, and 5 to generate the
number to use in the randomize statement.

Thank you.
 
D

Duncan Bachen

Billy said:
I don't know if it is possible but here is what I would like to do if
possible. I have a table with two fields: Week (number) and Word(text). The
week field can contain numbers from 1 to 10. An example might be:
1 current
1 correct
2 devise
2 disrupt
etc.
I have a randomize statement that randomizes the words based on the index
number of the week. So if I wanted to get the words from week 1 the randomize
statement would use the index number 1 as the max value. The problem is, if I
enter a new word for week one, it is index number 4 and I want it included in
the week one list of randomized numbers. Is it possible to resort the data on
the week field and then have Access re-index? If so, I would then want to
count how many records there were in week 1, 2, 3, 4, and 5 to generate the
number to use in the randomize statement.

Thank you.

You can always create a query that sorts on the Week number and the
Word. This would ignore the order in which the items were entered into
the table.

You can also use DCount to determine of records for each week. Examples
below are code to be used in a function.

Example 1:
Dim intNumWords As Integer
intNumWords = DCount("[Week]","[tblMyWords]","[Week] = 1")

Example 2:
Dim intNumWords As Integer
Dim intWhichWeek as Integer

intWhichWeek = 2
intNumWords = DCount("[Week]","[tblMyWords]","[Week] = " & intWhichWeek)
 
G

Guest

I am not sure how that would work. Let me try it this way. Currently I have
225 words, 25 in each week. The randomize statement is hard coded to
randomize the first 125 records because they are input in the correct order.
Also, I may change the number of words to each week to say - 15 in which case
the first five weeks would randomize to 75 (the 5 weeks with 15 words). I can
logic how I could set the upper limit of the randomize statement if all the
weeks and words are in order. But, if I were to increase 15 words per week to
25, then the records are not in sequencial order and I don't know how to
reorder the records to get the weeks in sequencial order by week. Hopes that
makes sense.

Thanks

Duncan Bachen said:
Billy said:
I don't know if it is possible but here is what I would like to do if
possible. I have a table with two fields: Week (number) and Word(text). The
week field can contain numbers from 1 to 10. An example might be:
1 current
1 correct
2 devise
2 disrupt
etc.
I have a randomize statement that randomizes the words based on the index
number of the week. So if I wanted to get the words from week 1 the randomize
statement would use the index number 1 as the max value. The problem is, if I
enter a new word for week one, it is index number 4 and I want it included in
the week one list of randomized numbers. Is it possible to resort the data on
the week field and then have Access re-index? If so, I would then want to
count how many records there were in week 1, 2, 3, 4, and 5 to generate the
number to use in the randomize statement.

Thank you.

You can always create a query that sorts on the Week number and the
Word. This would ignore the order in which the items were entered into
the table.

You can also use DCount to determine of records for each week. Examples
below are code to be used in a function.

Example 1:
Dim intNumWords As Integer
intNumWords = DCount("[Week]","[tblMyWords]","[Week] = 1")

Example 2:
Dim intNumWords As Integer
Dim intWhichWeek as Integer

intWhichWeek = 2
intNumWords = DCount("[Week]","[tblMyWords]","[Week] = " & intWhichWeek)
 
D

Duncan Bachen

Billy said:
I am not sure how that would work. Let me try it this way. Currently I have
225 words, 25 in each week. The randomize statement is hard coded to
randomize the first 125 records because they are input in the correct order.
Also, I may change the number of words to each week to say - 15 in which case
the first five weeks would randomize to 75 (the 5 weeks with 15 words). I can
logic how I could set the upper limit of the randomize statement if all the
weeks and words are in order. But, if I were to increase 15 words per week to
25, then the records are not in sequencial order and I don't know how to
reorder the records to get the weeks in sequencial order by week. Hopes that
makes sense.

Actually it doesn't make sense to me. I tried following you on this, and
I'm really lost.

Maybe you can post some code regarding this whole randomize thing, as
well as breaking your needs down into a simplier explanation of what
you're trying to accomplish, not how you're doing it now.

e.g. I'm trying to take make a report with a list a vocabulary words and
randomize the order in which they are printed (not the order in which
they were entered), based on their week number. Here's the code I have
so far:
 

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

Top