Hi, I have two txt boxes that I use to filter down a list of projects. The results are shown in a listBox. No results are shown when I use criteria in both boxes (the else statement below). Individual boxes work fine when the other box is empty.
Can anyone see why the else part of my code will not pull back the required records? Everything else appears to work fine!
If IsNull(txtRefFind.Value) And IsNull(txtTitleFind.Value) Then
'pull back all projects
lstResults.RowSource = "select * from tblPortfolio order by Ref_No"
ElseIf IsNull(txtTitleFind.Value) And txtRefFind.Value <> "" Then
'pull back only those where Ref Number partially match
lstResults.RowSource = "select * from tblPortfolio where Ref_No like '*" & txtRefFind.Value & "*'"
ElseIf IsNull(txtRefFind.Value) And txtTitleFind.Value <> "" Then
'pull back only those where Title partially match
lstResults.RowSource = "select * from tblPortfolio where Study_Title like '*" & txtTitleFind.Value & "*'"
Else
'pull back those where Ref Number and Title partially match
lstResults.RowSource = "select tblPortfolio.* from tblPortfolio where tblPortfolio.Ref_No Like '*" & txtRefFind.Value & "*' And where tblPortfolio.Study_Title Like '*" & txtTitleFind.Value & "*'"
End If
Thanks
BH
Can anyone see why the else part of my code will not pull back the required records? Everything else appears to work fine!
If IsNull(txtRefFind.Value) And IsNull(txtTitleFind.Value) Then
'pull back all projects
lstResults.RowSource = "select * from tblPortfolio order by Ref_No"
ElseIf IsNull(txtTitleFind.Value) And txtRefFind.Value <> "" Then
'pull back only those where Ref Number partially match
lstResults.RowSource = "select * from tblPortfolio where Ref_No like '*" & txtRefFind.Value & "*'"
ElseIf IsNull(txtRefFind.Value) And txtTitleFind.Value <> "" Then
'pull back only those where Title partially match
lstResults.RowSource = "select * from tblPortfolio where Study_Title like '*" & txtTitleFind.Value & "*'"
Else
'pull back those where Ref Number and Title partially match
lstResults.RowSource = "select tblPortfolio.* from tblPortfolio where tblPortfolio.Ref_No Like '*" & txtRefFind.Value & "*' And where tblPortfolio.Study_Title Like '*" & txtTitleFind.Value & "*'"
End If
Thanks
BH