我在Access中遇到了兩個與我的VBA有關的問題,第一個是當我單擊Search按鈕時什麼都沒有發生,第二個是說明theres與ME子句有錯誤。當我點擊它時,我的事件過程沒有任何作用
Private Sub Search_Click()
Dim strWhere As String, lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
strWhere = ""
If Not IsNull(Me.AssignedTo) Then
strWhere = strWhere & "([AssignedTo] Like '*" & Me.AssignedTo & "*') AND"
End If
If Not IsNull(Me.OpenedBy) Then
strWhere = strWhere & "([OpenedBy] Like '*" & Me.OpenedBy & "*') AND"
End If
If Not IsNull(Me.Status) Then
strWhere = strWhere & "([Status] Like '*" & Me.Status & "*')AND"
End If
If Not IsNull(Me.Category) Then
strWhere = strWhere & "([Category] Like '*" & Me.Category & "*')AND"
End If
If Not IsNull(Me.Priority) Then
strWhere = strWhere & "([Priority] Like '*" & Me.Priority & "*')AND"
End If
If Not IsNull(Me.OpenedDateFrom) Then
strWhere = strWhere & "([EnteredOn] >= " & Format(Me.OpenedDateFrom, conJetDate) & ") AND "
End If
If Not IsNull(Me.DueDateFrom) Then
strWhere = strWhere & "([EnteredOn] <= " & Format(Me.DueDateFrom, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
End If
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End Sub
任何幫助表示讚賞
我很困惑。如果點擊搜索時沒有任何反應,您怎麼知道第二個問題? BTB,你應該一次只問一個問題,嘗試通過調試或使用MsgBox進行測試,例如。 MsgBox(Me.Status) –
因爲我創建了一個宏並運行它,調試問題出現了。 – user3666237
你知道事件過程爲什麼沒有做任何事嗎? – user3666237