用下拉列表填充表单-访问 [英] Populating a form with a dropdown - Access
问题描述
我正在尝试在访问中创建一个表单,该表单的顶部具有一个下拉菜单,并将用与所选内容相对应的记录填充表单的其余部分.
I am trying to create a form in access that has a dropdown at the top and will populate the rest of the form with the record that corresponds to what is chosen.
我在网上查看了2种不同的指南,但都指向Access的旧版本,我认为我缺少一些内容.
I have looked at 2 different guides online but both point to older versions of Access and I think I am missing something.
所以.我做所有事情的顺序:
So. The order that I did everything:
-
我去了表格.然后我单击了表单.这样就形成了一个快速表单,其中所有字段均为文本框.
I went to the table for the form. And I clicked Form. This made a quick form with all of the fields as text boxes.
我删除了将成为下拉菜单的字段,并放入了一个下拉菜单以取消向导
I deleted the field that will be the dropdown and I put in a dropdown canceling the wizard
在下拉菜单的数据部分中.我编辑了行源"以按顺序选择下拉列表中的字段和唯一ID.
In the data section for the dropdown. I edited "Row Source" to select the field that will be in the dropdown and the unique ID, in that order.
我将绑定列设置为2(我都尝试过)
I set the bound Column to 2 (I have tried both)
我将组合框的名称设置为"TitleSelector"
I set the name of the Combo Box to "TitleSelector"
在表单设置"中.对于记录源".我在"ID"的条件中有"[表单]!.[TitleSelector]&"*".我还列出了查询中的其余字段
In Form Settings. For "Record Source". I have "[forms]!.[TitleSelector] & "*" in Criteria for "ID". I also have the rest of the fields in the Query listed
我在更改时添加了"me.requery" 不知道这是否意味着什么.当我输入"ID"的条件时,下拉菜单中没有显示"TitleSelector".
I added the "me.requery" to on change Not sure if it means anything. When I was typing in the Criteria for "ID" it did not show "TitleSelector" in the drop down.
我正在使用Access 2010
I am using Access 2010
我的问题 - 下拉菜单本身可以正确显示所有内容.但是,当我选择某些东西时,什么也没发生
My Problem - The dropdown itself shows everything correctly. However nothing happens when I choose something
SELECT Pieces.ID, Pieces.Title, Pieces.Composer, Pieces.Instrumentation, Pieces.Location, Pieces.Location_2
FROM Pieces
WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector]));
这是我的数据库副本的链接: https://www.dropbox. com/s/tpnqm686tj653fg/Trisha%20Database.accdb
Here is a link to a copy of my database: https://www.dropbox.com/s/tpnqm686tj653fg/Trisha%20Database.accdb
推荐答案
将me.requery添加到ON CHANGE事件中 (选择CODE BUILDER-然后在其中输入me.requery)应该可以正常工作.
Adding the me.requery to the ON CHANGE EVENT (select CODE BUILDER - and enter the me.requery there) should work.
这篇关于用下拉列表填充表单-访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!