0

I have a datasheet form ItemsForm based on table Items. Items is one-to-many related to table StatusHistory, between Items.ID and StatusHistory.ItemID. There is also a Status table, with the relationship between Status.ID and StatusHistory.StatusID.

I want to add a StatusBox combo box to ItemsForm so that when the user selects a Status value from the box and then moves out of the record, which should trigger the Form_BeforeUpdate() event, a new entry is added to StatusHistory with the Items.ID of the currently selected entry.

I've successfully added the StatusBox field to the form and populated its list by setting its RowSource with a query of Status. But there are two big problems:

  1. I can scroll through the values in the box's list, but after I select one, it doesn't show up in the field; the field stays blank.

  2. When I select a value in StatusBox, and then click onto another record, the Form_BeforeUpdate() isn't triggered. It seems that Form_BeforeUpdate() is only triggered if I modify data in the fields from Items that the form is based on. Is there a different event that I should be using here?

4

1 回答 1

1

解决如下:

  1. 的 ID 字段Status实际上是命名StatusID而不是 ID. 修复此问题后,我可以在该字段中输入值。

  2. 我将代码放入BeforeUpdate()事件中StatusBox,即:

Private Sub StatusBox_BeforeUpdate(Cancel As Integer)

End Sub

这意味着每当我在列表中选择一个项目时都会触发它,而不是当我移动到新记录时,但现在这就是我所需要的。

于 2013-07-09T23:46:32.783 回答