admin管理员组

文章数量:1425791

I have a textbox in Form2 named txtEID with an Employee ID value that is passed from another form.

I also have a sample textbox named txtFullName that should autopopulate the name of a person from table tblEmployees with table field EmployeeName where Form2.txtEID.value is equal to EID of tblEmployees.

I don't know how to autopopulate the textbox.
I tried a ComboBox with this line in its Rowsource property:

SELECT [tblEmployees].[ID], [tblEmployees].[EmployeeName] FROM tblEmployees WHERE [tblEmployees].[EID] = [txtEID]; 

It is showing the desired value (person's name based on EID of txtEID) in the ComboBox but only as a dropdown list.

How can I set the value of the textbox txtFullName to a person's name from the table based on the EID showing in txtEID?
I also don't know how to set it up in the txtFullName Control Source property.

I have a textbox in Form2 named txtEID with an Employee ID value that is passed from another form.

I also have a sample textbox named txtFullName that should autopopulate the name of a person from table tblEmployees with table field EmployeeName where Form2.txtEID.value is equal to EID of tblEmployees.

I don't know how to autopopulate the textbox.
I tried a ComboBox with this line in its Rowsource property:

SELECT [tblEmployees].[ID], [tblEmployees].[EmployeeName] FROM tblEmployees WHERE [tblEmployees].[EID] = [txtEID]; 

It is showing the desired value (person's name based on EID of txtEID) in the ComboBox but only as a dropdown list.

How can I set the value of the textbox txtFullName to a person's name from the table based on the EID showing in txtEID?
I also don't know how to set it up in the txtFullName Control Source property.

Share Improve this question edited Apr 1 at 4:27 CommunityBot 11 silver badge asked Dec 30, 2024 at 6:10 ShielaShiela 7491 gold badge9 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Use DLOOKUP in the Control Source to pull the information.

DLookUp("[Full_Name]","[Table1]","[EID]=" & [txtEID])

I've wrapped it in an IIF statement as it returns an error if the txtEID control on the form is null.

=IIf(IsNull([txtEID]),"",DLookUp("[Full_Name]","[Table1]","[EID]=" & [txtEID]))

本文标签: