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.
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]))
本文标签:
版权声明:本文标题:vba - How to pull a value from a table in Access and show it in a textbox based on a unique ID displayed in another textbox? - S 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745413533a2657577.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论