Updating a field in a table upon update


I need to update a field in my tbl_reference table once a new record is added. The field is going to be used by users to identify each record.  The field name is unique_reference and needs to include

me.batch_reference (text)
and an increasing number 0001

for example:

The first half before the "/" is the batch_reference field and I was trying to base the "0001" part in the ID field which is an autonumber field.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
to get the format you need to concatenate the batch_reference field and the autonumber

[batch_reference] & "/" & format([autonumber field],"0000")
anthonytrAuthor Commented:
Where is the best place to add this code?  I have tried BeforeUpdate and AfterUpdate but keep getting errors:

I'm using:

Me.unique_reference = "REF" & "/" & Format([id], "0000")
Rey Obrero (Capricorn1)Commented:
you can use the afterUpdate of a any of the field that should have entry or a required field

Me.unique_reference = "REF/" & Format([id], "0000")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hamed NasrRetired IT ProfessionalCommented:
I suggest having 2 fields one for ref, and second for seq in each ref.
seq is calculated as DMax + 1 of existing seq for each ref.

See this sample database.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.