[英]What's wrong with this code for filtering data?
Private Sub txtSearchJobNo_AfterUpdate()
Dim rst As DAO.Recordset, strCriteria As String
strCriteria = "[A_JOBNO]=" & txtSearchJobNo
Me.FilterOn = False
'-- Me.Filter = strCriteria
Me.FilterOn = True
Set rst = Me.RecordsetClone
rst.FindFirst(strCriteria"[A_JOBNO]=" & txtSearchJobNo)
If rst.NoMatch Then
MsgBox "No entry found"
Else
Me.Bookmark = rst.Bookmark
End If
End Sub
以上是我試圖根據用戶輸入到文本框來過濾表單數據的代碼。絕對沒有任何事情發生。
您需要文本字段的引號。
Private Sub txtSearchJobNo_AfterUpdate()
Dim rst As DAO.Recordset, strCriteria As String
strCriteria = "[A_JOBNO]=" & txtSearchJobNo
Set rst = Me.RecordsetClone
rst.FindFirst(strCriteria"[A_JOBNO]='" & txtSearchJobNo) & "'"
If rst.NoMatch Then
MsgBox "No entry found"
Else
Me.Bookmark = rst.Bookmark
'Filter here or bookmark, not both
End If
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.