简体   繁体   English

如何根据 Access 2013 中第一个字段的选择来自动填充第二个字段?

[英]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 WHMIS 365 天
  2. Fall Protection 1095 Days坠落保护 1095 天

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 John Doe WHMIS 2015 年 12 月 12 日
  2. John Doe Fall Protection Jan 3 2014 John Doe Fall Protection 2014 年 1 月 3 日
  3. Jane Doe WHMIS Feb 3 2016 Jane Doe WHMIS 2016 年 2 月 3 日

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函数:

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]字段,如下所示:

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.由于您不提供表或字段名称,或者您的表是否使用 ID 正确构建,因此我只能为您提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何基于Access 2013中另一个输入的字段更新表单上的字段? - How do I update a field on a form based on another entered field in Access 2013? 如何根据字段值限制访问中的记录创建? - How can I restrict record creation in access based on a field value? Ms Ms:如何使用表单中的字段填充表格? - Ms Access: How do I populate a table using a field in a form? Microsoft Access 2013字段权限 - Microsoft Access 2013 Field Permissions 如何在mysql中根据姓氏和名字自动填充名称? - How to auto populate a name based on first and last name in mysql? 如何为 SQLite auto_increment 字段添加前缀? - How can I add prefix to SQLite auto_increment field? 我可以在INSERT期间重复使用AutoNumber值来填充另一个字段吗? C#和访问数据库 - Can I re-use AutoNumber value during INSERT to populate another field? C# & Access Database SQL - 我可以将表主键基于多个字段,要求第一个或第二个值的唯一性吗? - SQL - Can I base a table primary key on more than one field, requiring the uniqueness of first OR second value? 如何根据两个字段值导出唯一文档? - How can I export unique documents based on two field values? MS Access 2003-基于以前的表单域自动填充表单域。 - MS Access 2003 - Auto fill form-field based on previous form field.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM