Access- Open form with where clause

徘徊边缘 提交于 2019-12-25 08:49:56

问题


I need to open a specific form by a click on a subform record name. The name in the subform is showed as a combobox with ID and Name as columns.

I did like this:

Private Sub ID_Prodotto_DblClick(Cancel As Integer)
Dim Id As Integer
Id = Me.ID_Prodotto.Column.Value
DoCmd.OpenForm "Prodotto", , , "ID_Prodotto = " & Id
End Sub

But Access requires me to manually insert the ID Field Value as I click on the record. Where am I wrong?


回答1:


It should read:

Id = Me!ID_Prodotto.Value

or, if you wish to use the value from column number n (0 is the first):

Id = Me!ID_Prodotto.Column(n)


来源:https://stackoverflow.com/questions/45588915/access-open-form-with-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!