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.
1 Answer
Reset to default 2Use 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]))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745413533a4626641.html
评论列表(0条)