[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

How do I Create a unique identifier from field value plus date

Hello experts and happy friday.

I'm hoping the following can be done relatively easily.

I have a field on a form called 'CallID' I want to populate the field with an identifier that is a combination of another field (UserID) and the date & Time that the event was recorded.

Can it be done?
What do you call the procedure?
How do Ido it?

Thanks for your help.

1 Solution
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
First: I'd suggest you NOT use this as your Primary Key value for the field, and in fact you probably shouldn't even use this as a Unique value, since I assume you already have the root data (the UserID and DateTime of Call) stored in your database. Instead, use an AutoNumber field as a surrogate PK field.

If you want to DISPLAY this on a form or query, just include a concatenated field in your query or form. For example, in a form's Textbox, use this as the ControlSource:

=YourUserIDField & YourDateTimeField

You'd obviously have to change it to reflect your actual fields, but this would display your field.

You can do the same in a query:

SELECT Col1, Col2, YourUserIDField & YourDateTimeField AS SomeFieldName FROM YourTable

This would output that concatenated field in your query.
dj1710Author Commented:

I ended up going with =UserID&Now()

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now