BTW: to make this kind of queries more readable, it is common practice to the whole boolean logic part (the part in the where statement) inside a function:
Function CheckValues(val1 As String, val2 As String) As Boolean
' do your thing here
End Function
and then, the where part becomes:
where CheckValues(value1, value2)
etc.
Main Topics
Browse All Topics





by: abelPosted on 2009-08-12 at 16:19:14ID: 25084070
Yes, you can use IIF, and no, you cannot use select case.
The problem with IIF is that all parts are evaluated (even if the first part is false), so that's not a solution. What you need is AndAlso, which will only evaluate the first part and stop then if it is false (because there's no need to continue), the counterpart for Or is OrElse:
where value1 = strvalue1 AndAlso (value2 Is Nothing OrElse value2 = strvalue2)