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

StackOverflow https://stackoverflow.com/questions/21692369

Question

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.

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top