Vulcan1500
Registered User.
- Local time
- Tomorrow, 00:03
- Joined
- Nov 13, 2007
- Messages
- 143
I have a form with a listbox. This listbox shows all records of a database. With help of this forum I'm able to sort the listbox ascending and decending by clicking the individual fields in the header. Now I have put 6 controls(textboxes) in the footer of the form with a button to find records. My question is now how to handle the strWhere so that at opening all data and after search part of the data is shown
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.txtYearSurvey) Then
strWhere = strWhere & "([YearSurvey]=" & Me.txtYearSurvey & ") AND "
End If
If Not IsNull(Me.txtYearExecution) Then
strWhere = strWhere & "([YearExecution]=" & Me.txtYearExecution & ") AND "
End If
If Not IsNull(Me.txtProjectNo) Then
strWhere = strWhere & "([ProjectNo]=""" & Me.txtProjectNo & """) AND "
End If
If Not IsNull(Me.txtProjectName) Then
strWhere = strWhere & "([ProjectName]Like ""*" & Me.txtProjectName & "*"") AND "
End If
If Not IsNull(Me.txtArea) Then
strWhere = strWhere & "([Area]=""" & Me.txtArea & """) AND "
End If
If Not IsNull(Me.txtCountry) Then
strWhere = strWhere & "([Country]=""" & Me.txtCountry & """) AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Me.lstTSHDAdvancedSearch.RowSource = strWhere
Me.lstTSHDAdvancedSearch.Requery
End If
End Sub
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.txtYearSurvey) Then
strWhere = strWhere & "([YearSurvey]=" & Me.txtYearSurvey & ") AND "
End If
If Not IsNull(Me.txtYearExecution) Then
strWhere = strWhere & "([YearExecution]=" & Me.txtYearExecution & ") AND "
End If
If Not IsNull(Me.txtProjectNo) Then
strWhere = strWhere & "([ProjectNo]=""" & Me.txtProjectNo & """) AND "
End If
If Not IsNull(Me.txtProjectName) Then
strWhere = strWhere & "([ProjectName]Like ""*" & Me.txtProjectName & "*"") AND "
End If
If Not IsNull(Me.txtArea) Then
strWhere = strWhere & "([Area]=""" & Me.txtArea & """) AND "
End If
If Not IsNull(Me.txtCountry) Then
strWhere = strWhere & "([Country]=""" & Me.txtCountry & """) AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Me.lstTSHDAdvancedSearch.RowSource = strWhere
Me.lstTSHDAdvancedSearch.Requery
End If
End Sub