콤보 상자에서 입력하거나 선택한 문자열을 사용하여 연속 양식을 필터링해야한다는 요구 사항이 있습니다. 아래는 필터 문자열을 캡처하는 데 사용하려고 시도하는 코드입니다. 무슨 일이 일어날 지, 뒤에서 잡히는 문자열이 아닌 목록에 텍스트가 입력되면 콤보 상자가 Null임을 나타내는 오류가 대신 발생합니다.MS 액세스 필터 연속 양식
어디에서이 기능을 사용할 수 있습니까? 나는 단지 Combobox_Selected 이벤트에 코드를 추가하는 것을 고려하고있다. 그러나 그것은 사용자가 폼의 내용을 추가로 필터링 할 수있는 임의의 키워드를 입력 할 수있는 능력을주지 않을 것이다.
Private Sub txtUSPSKeySearch_Change()
On Error GoTo Err_txtUSPSKeySearch_Change
Dim searchStr As String
searchStr = txtUSPSKeySearch.Value
If (Not IsNull(searchStr) And Len(searchStr) > 1) Then
Else
' Move the cursor to the end of the combo box.
Me.txtUSPSKeySearch.SetFocus
Me.txtUSPSKeySearch.SelStart = Len(Me.txtUSPSKeySearch.Value)
End If
'Error Handling
Exit_txtUSPSKeySearch_Change:
Exit Sub
Err_txtUSPSKeySearch_Change:
If Err.Number = 5 Then
MsgBox "You must make a selection(s) from the list" _
, , "Selection Required !"
Resume Exit_txtUSPSKeySearch_Change
Else
'Write out the error and exit the sub
MsgBox Err.Description
Resume Exit_txtUSPSKeySearch_Change
End If
End Sub