Query compare

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

Guest

Using A2K, is there a way to select every nth record in a table using the
Autonumber ID of the table?
If I want every 8th record, only retrieve record 1, 9, 17, 25, etc for the
entire table.

Thanks for any help.

danc09
 
Yes and no. It is possible to do using the example you have given; however,
it won't adapt for missing auto numbers. For example, with the list you
gave, if 9 was missing, it would return 1, 17, and 25. Just a caution here,
auto numbers are NOT meant to be relevant, just unique. If you are using
them for anything other than a unique id for the record, you'll run into
problems.

To do what you are asking for, create a calculated field in the query (you
can uncheck the Show box, if desired, for this field). The criteria for the
field will be 0 (zero).

MyEighthField: ([AutoNumberField] + 7) Mod 8

The +7 is to allow for the fact that you want to start with 1 being returned
instead of starting with 8 as the first returned value. The Mod function
returns the remainder of a division problem, so if the current value is 1,
you add 7 to get 8 then divide by 8. This gives a remainder of 0. You should
also be able to skip the addition and just change the criteria to 1 instead
of 0. 1 Mod 8 = 1, 9 Mod 8 = 1, etc.
 

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