简体   繁体   English

表单Dlookup文本框控件源

[英]Form Dlookup textbox Control Source

I am building a form and having trouble with getting the DLookup to function correctly. 我正在构建表单,但无法使DLookup正常运行。

Here is what I have. 这就是我所拥有的。 I have a query which contains employee information relating to Profits and Loss. 我有一个查询,其中包含与损益有关的员工信息。 so things like name, salary, etc. 诸如姓名,薪水等

Now I am creating a form where I can see a listbox of my employees on the left and when I click on one of the entries in the listbox it populates a series of text boxes with the various values of the fields from that specific record. 现在,我正在创建一个窗体,在该窗体中,我可以在左侧看到我的员工的列表框,当我单击列表框中的一个条目时,它会填充一系列文本框,其中包含该特定记录中各个字段的值。

I am using access 2007 I built a listbox off a query which contains all the fields that I want to get the data populated from. 我正在使用Access 2007,我从一个查询中构建了一个列表框,其中包含我要从中填充数据的所有字段。 however I am having trouble configuing the Control source of the text boxes so that they will populate with that employee's data. 但是,我在配置文本框的“控制”源时遇到了麻烦,因此无法使用该员工的数据来填充它们。

Could someone please help? 有人可以帮忙吗? Should I use a VBA onclick event instead or is there a way I can get the effect that I am looking for simply by modifying the Control source for the specific textboxes that I want to populate? 我应该改用VBA onclick事件,还是可以通过简单地修改要填充的特定文本框的“控件”源来获得想要的效果?

"I built a listbox off a query which contains all the fields that I want to get the data populated from" “我在查询中构建了一个列表框,其中包含我要从中填充数据的所有字段”

Since the listbox columns contain everything you need to populate the text boxes, use the list box's After Update event to load the text boxes. 由于列表框列包含填充文本框所需的所有内容,因此请使用列表框的After Update事件加载文本框。

Me.TextBox1.Value = Me.YourListBox.Column(0)
Me.TextBox2.Value = Me.YourListBox.Column(1)
Me.TextBox3.Value = Me.YourListBox.Column(2)

Notice the listbox column numbering starts from zero. 请注意,列表框的列编号从零开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM