Main Page ┬╗ MS Access Functions ┬╗ Equivalent of Mod function in MS Access


Equivalent of Mod function in MS Access


MS Access does not have built-in 'mod' function even though Access VBA has. You can use the following code to provide the same purpose.
Let's have a look where can we use this snippet;
When you want to split more than one part your huge database, you may prefer to use mod function.
For example; you have huge database that contains over four millions records (we imagine that database has numeric field (like ID or customer number)) and we want to export it separated MS Excel files.

sample.txt
RESULT: [YOUR_NUMERIC_FIELD]-(MOD_BASE * Fix([YOUR_NUMERIC_FIELD / MOD_BASE)) 

e.g. for splitting four parts to huge MS Access file we must use mod 4.
(After divided by 4, remainder must be 0, 1, 2, 3).

sample.txt
RESULT: [YOUR_NUMERIC_FIELD]-(4 * Fix([YOUR_NUMERIC_FIELD / 4)) 

Then filter by result for each reminder (0, 1, 2, 3) value to get smaller pieces of database.
You can download running sample from below link.
Download example file


´╗┐