开发者

How to bind the contents of a combo box to the value of another

I curren开发者_如何学运维tly have two comboboxes on a form. The first combobox contains a list of items. I want the second combobox to repopulate whenever the first one is changed. The query that returns contents of the second box will use the PK value from the first box.

So basically the second combobox is bound to the query (example):

SELECT a.ID, a.description
FROM a
WHERE a.FK = [forms]![cbo1]

really generic example. This isn't working for me right now. Is there a way to do this, or am i going to have to do it in code?


You have to add an onChange event to the first box. Click on the properties of the first box, then on the event tab and the elipses(...) next to the onChange field. Pick the code editor that will take you to a VBA window where you can instruct the second box to refresh. So if your second combo box is called cmbA you would have

cmbA.Requery

in the event handler method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜