MS Access - Setting default value of a field to be the values of two other fields, seperated by an'_'

别等时光非礼了梦想. 提交于 2019-12-13 04:35:01

问题


A form that I have at the moment has the field, Skill_Name.

There is a subform with two fields; Employee_ID (A combo box of all Employee_IDs) and Emp_Skill_ID.

Upon selecting an Employee_ID, I'd like the Emp_Skill_ID to autofill in the following format:

Employee_ID_Skill_Name

Example: If Employee ID = 1234567, and Skill Name = AutoElec, I want the Emp_Skill_ID to automatically be 1234567_AutoElec.

If that's at all possible, it'd be much appreciated if someone could tell me how to do it.

Regards, AUS_Doug.


回答1:


you need to handle the AfterUpdate in both Employee_ID and SkillName. Something like

Private Sub Employee_ID_AfterUpdate()
    UpdateEmp_Skill_ID
End Sub

Private Sub SkillName_AfterUpdate()
    UpdateEmp_Skill_ID
End Sub

Private Sub UpdateEmp_Skill_ID
   If Not IsNull(Employee_ID) And Not IsNull(SkillName) Then
        Emp_Skill_ID = Employee_ID & "_" & SkillName
   End If
End Sub


来源:https://stackoverflow.com/questions/21692369/ms-access-setting-default-value-of-a-field-to-be-the-values-of-two-other-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!