Return full value of field in Query?

willlobb

Board Regular
Joined
Mar 29, 2002
Messages
103
Hi all,

I am creating a query to give each student in my database a Student Number based on values for their record in the Student tbl.

[tblStudent]

Student ID (00001, 00002, 00003, etc.)
Student Name (John Smith)
School ID (101, 102, 103, etc.)
Joining Year (2011, 2012, etc.)

My query creates a calculated field: Student Number where:

Student Number: "BR" & [Joining School ID] & "-" & Right([Joining Year],2) & "-" & [Student ID]

This gives something like: BR101-11-1

However, what I would like is BR101-11-00001 with the full value o the Student ID field.

Is there a function I can use to get the full value with all the 0000s?

Many thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:
Student Number: "BR" & [Joining School ID] & "-" & Right([Joining Year],2) & "-" & Format([Student ID],"00000")

Denis
 
Upvote 0
Hi Denis,

I had tried the Format function but had not put " " round the 00000, but that worked perfectly!

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

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