【发布时间】:2016-06-13 22:51:42
【问题描述】:
我正在尝试在我的桌子上的列表框控件中搜索当前选定的项目。
在更新事件后的列表框控件中,我有这段代码
Private Sub lst_MainList_AfterUpdate()
Dim theDB As DAO.Database
Dim theProposalsTable As DAO.Recordset
Set theDB = CurrentDb
Set theProposalsTable = theDB.OpenRecordset("tbl_PROPOSAL", dbOpenDynaset)
theSeeker theProposalsTable, Me.lst_PPpg_MainList.Value
End Sub
然后我的 Module1 上有一个带有此代码的子。我从一个示例代码 @https://msdn.microsoft.com/en-us/library/office/ff836416.aspx
中得到了这个Sub theSeeker(ByRef rstTemp As Recordset, intSeek As Integer)
Dim theBookmark As Variant
Dim theMessage As String
With rstTemp
' Store current record location.
theBookmark = .Bookmark
.Seek "=", intSeek
' If Seek method fails, notify user and return to the
' last current record.
If .NoMatch Then
theMessage = "Not found! Returning to current record." & vbCr & vbCr & "NoMatch = " & .NoMatch
MsgBox theMessage
.Bookmark = theBookmark
End If
End With
End Sub
我收到运行时错误 3251 Operation is not supported for this type of object.
当我点击调试时,它会突出显示.Seek "=", intSeek
【问题讨论】: