我有一个连续的表格 - 表格上的字段之一是 RecordID。
我在该表单上有一个标签,单击该标签时应通过 VBA 生成一个带有 RecordID 的消息框:
MsgBox Me.RecordID
标签复制在连续表格的每一行上,但只会引用第一条记录。尽管我可以看到表单的每一行中的 RecordID 字段都不同,但我总是得到相同的结果,在本例中为 80029。
那是怎么回事?
我有一个连续的表格 - 表格上的字段之一是 RecordID。
我在该表单上有一个标签,单击该标签时应通过 VBA 生成一个带有 RecordID 的消息框:
MsgBox Me.RecordID
标签复制在连续表格的每一行上,但只会引用第一条记录。尽管我可以看到表单的每一行中的 RecordID 字段都不同,但我总是得到相同的结果,在本例中为 80029。
那是怎么回事?
Me.RecordID
refers to the RecordID
of the current record, as indicated by the black triangle in the record selector:
A Label
control on a form cannot receive the Focus
, so when you click on the label in another record the current record does not change and you keep getting the same RecordID
. Note that if you put the same code into the Click
handler for a textbox (or some other control that can receive the Focus
) then the current record will change and you'll get the RecordID
of that record.