简体   繁体   中英

How can I get a second field to auto populate based on the selection of the first field in Access 2013?

I am trying to build a training record database. In our company, employees have to take a variety of different training and each certification has a different expiry timeline.

My first table lists out ALL the training along with the number of days they are valid for like so:

  1. WHMIS 365 Days
  2. Fall Protection 1095 Days

My second table will simply list out all the employees and each of their training and the date they took it.

For ex:

  1. John Doe WHMIS Dec 12 2015
  2. John Doe Fall Protection Jan 3 2014
  3. Jane Doe WHMIS Feb 3 2016

How can I get a forth field, to automatically calculate the Expiry date, based off of the number of days the certification is valid in the first table?

You need the DateAdd function like this:

DateAdd("d",[NoOfdays],[TrainingDate])

How you will use that depends on what you are trying to do. If you just want to have it somewhere create a query that links the two tables together based on employee and add the above as a field.

If you don't want to link the tables you can use DLookup to read the [NoOfDays] field like this:

DLookup("[NoOfdays]","[TrainingTable]","[TrainingCourse]=" & [TrainingCourse])

Since you don't provide the table or field names, or whether your tables are properly structured with IDs or not that's as far as I can get you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM