Generating unique code number

Mudface

MrExcel MVP
Joined
Feb 18, 2002
Messages
3,339
I'm currently struggling a bit with an Incidents database. I have a main table for entry of incident details, linked one-to-many with an actions table via the incidents RefNo field.

What I would like to do is generate an Action code number for each action consisting of the RefNo and the Action number, as shown below. I can do this via concatenation of the RefNo and ActionID (autonumber primary key) but as shown, the action number must 'reset' itself for each new incident RefNo, and I can't work this out. Is it possible to do this via a query, or am I looking at using code?
Book1
ABCD
1RefNoActionIDActionNumberActionCode
201/FA/031101/FA/03-1
301/FA/032201/FA/03-2
401/FA/033301/FA/03-3
501/FA/034401/FA/03-4
602/FA/035102/FA/03-1
703/FA/036103/FA/03-1
803/FA/037203/FA/03-2
903/FA/038303/FA/03-3
Sheet1
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
A pattern as shown in column D above. I could use the ActionID autonumber field in the concatenation, but that would give non-sequential numbers, each action for each RefNo should be numbered sequentially as shown.
 
Upvote 0

Forum statistics

Threads
1,221,503
Messages
6,160,193
Members
451,630
Latest member
zxhathust

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top