You are here:

Using MS Access/Auto Populate a Text Field based on date in other info provided

Advertisement


Question
QUESTION: I am a Drug Recognition Expert and need to create a form to track the evaluations I do and other do.  In a form I want the rolling log number to auto populate with an ID number.  The number would be the two digit year, then a "-" then the individual's badge number, then the number in that year the eval was.  So for example it is the year 2013, the officer's badge number is 514 and then the numbers would be in sequential order. So it would go for 2013 like this:  13-514-1, 13-514-2, 13-514-3, 13-514-4 and so on.  But once the year changes then it would be 14-514-1, 14-514-2, 14-514-3 and so on.  So it is based on the year and the officer's badge number then in sequential order.  Is there a way to make an autoID automatically populate like this?

ANSWER: Yes, please see my blog entry on Sequential Numbering. It explains how to do this. Please note, that you should NOT store this ID. I assume you are already capturing the date and badge number in other fields of the record. So all you need do is add a sequential number to the record.

You can then display the ID whenever needed using an expression.

If you have any questions after reviewing the blog please feel free to ask.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

---------- FOLLOW-UP ----------

QUESTION: I appriciate the quick response.  I do need to store the information as it will ne to be on any rolling log reports.

ANSWER: I'm not sure what you mean by that. Are the date and Badge number currently part of the table record?

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

---------- FOLLOW-UP ----------

QUESTION: I need the rolling log number which is the two digit year-officer's badge number-sequential number to show up on a report that is requested.  So the 13-514-1 and so on for each record would need to be displayed on a report form from access.  So each record would have this number on the report.

Answer
That's fine. You can do that without storing this number in a table. It is NOT necessary to store. It violates Normalization rules as its redundant data. My blog details how to do this. Essentially, you use an expression to concatenate the values already stored in the record. You DO need to store the components of this ID, you DO NOT need to store the ID itself.

You can either add a calculated column to a query that serves as the report's Recordsource or use an expression as the ControlSource of a control on your report.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.