Skip to content
Advertisement

How to generate a sequence of ID’s based on mapping tables and values from the forms in MS-Access (Sql)?

I want to generate ID’s based on the form values in MS-Access. And then for each ID generated, create a group of ID’s by adding another 4 digits in the end based on a Mapping Table, representing different octets for different time points (12 ID’s based on the Initial ID and the mapping Table).

For example, if the ID generated based on form values is 123456, I want to add another four digits and create a group of ID’s, say from a mapping table. Like,

and so on.

So far each primary ID, I am slapping on four digits at the end and generating a group of 12 ID’s.

I am a beginner in Access and I have tried some code:

However, I get a error that Access does not recognize Map as a valid Field or expression. I am able to break down the problem into this. But could not find a way further and design a query.

Sample Data: (The short_ID and Long_ID tables, uses the mapping tables below each of them as shown.)

Short ID Table:

Mapping Tables for Short ID:

Map1 for Table1:

Map2 for Table1:

Long ID Table:(shown here are just examples for 2 time points rather than 12)

Timepoint Map for Long ID Table:

I need to generate these short and long ID’s from the mapping tables directly when input is given in the form. (Category, Organ_Type, Subject_ID)

tldr

  1. generate id from mapping table and form values (id creation)
  2. add four digits at the end and create a group of 12 id’s (long id creation) based on a mapping table (which has the 12 four digits that is to be appended in the end)

Advertisement

Answer

First, create a query, QShortID:

Output:

enter image description here

Next, create a query, Dozen, that will return 12 rows:

Finally, create a Cartesian (multiplying) query, QLongID:

Output:

QLongID

Edit:

To use the timepoint mapping, use:

Output:

enter image description here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement