많은 수의 레코드를 수용 할 데이터베이스를 구축 중이므로 서버에서 가장 쉬운 검색 기능을 원합니다. 다음 코드를 사용하고 있지만 큰 데이터베이스의 경우 지속 가능하지 않습니다. 이 검색 창을보고하고 검색 결과를 좁힐 수있는 쿼리를 실행중인 :대형 데이터베이스 용 MS Access 검색 양식
Private Sub SearchFor_Change()
'Create a string (text) variable
Dim vSearchString As String
'Populate the string variable with the text entered in the Text Box SearchFor
vSearchString = SearchFor.Text
'Pass the value contained in the string variable to the hidden text box SrchText,
'that is used as the sear4ch criteria for the Query QRY_SearchAll
SrchText.Value = vSearchString
'Requery the List Box to show the latest results for the text entered in Text Box
'SearchFor
Me.SearchResults.Requery
'Tests for a trailing space and exits the sub routine at this point
'so as to preserve the trailing space, which would be lost if focus was shifted from
'Text Box SearchFor
If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
'Set the focus on the first item in the list box
Me.SearchResults = Me.SearchResults.ItemData(1)
Me.SearchResults.SetFocus
'Requery the form to refresh the content of any unbound text box that might be feeding
'off the record source of the List Box
DoCmd.Requery
'Returns the cursor to the the end of the text in Text Box SearchFor,
'and restores trailing space lost when focus is shifted to the list box
Me.SearchFor = vSearchString
Me.SearchFor.SetFocus
Me.SearchFor.SelStart = Me.SearchFor.SelLength
Exit Sub
End If
'Set the focus on the first item in the list box
Me.SearchResults = Me.SearchResults.ItemData(1)
Me.SearchResults.SetFocus
'Requery the form to refresh the content of any unbound text box that might be
'feeding off the record source of the List Box
DoCmd.Requery
'Returns the cursor to the the end of the text in Text Box SearchFor
Me.SearchFor.SetFocus
If Not IsNull(Len(Me.SearchFor)) Then
Me.SearchFor.SelStart = Len(Me.SearchFor)
End If
가 이상적으로 여러 검색 필드가 양식을 원하는, 그리고 하나는에 결과를 반환하는 쿼리를 실행 버튼을 '발견' 리스트 박스.
사용자가 검색 결과에서 선택 항목을 두 번 클릭하면 선택한 레코드가 편집 모드의 양식으로 열리도록 설정하는 방법도 잘 모르겠습니다.
도움을 주시면 감사하겠습니다.
감사합니다. HK1. 이것은 매우 도움이되었습니다. 저는 여러분의 코드 제안을 독자적으로 채택하려고합니다. – intruesiive