|
-
August 8th, 2001, 04:04 PM
#1
How can i do this... seems very complex
I have four combo boxes on a form and a certain item from each combo box is to be selected. From the code below it works fine when all of the combo boxes have a selection, but how do i work around when only some of the boxes are selected or either none of them are selected. I know i should use the IsNull function but can't seem to come up a good idea of manipulating this.. by the way. "TableName" is a variable..
strSQL = "SELECT * FROM " & TableName & " WHERE" _
& " Project_Name = '" & ProgCombo.Column(0) _
& "' AND LRU = '" & LRUCombo.Column(0) _
& "' AND CSCI = '" & CSCICombo.Column(0) _
& "' AND Category = '" & CategCombo.Column(0) _
& Chr(39) & ""
Set rsRef = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
anyone have an idea or suggestion that can help me out? thanks in advance..
-
August 8th, 2001, 05:00 PM
#2
Re: How can i do this... seems very complex
Just a trick for me: And "1=1" at the beginning.
========
strSQL = "SELECT * FROM " & TableName & " WHERE 1=1"
If ProgCombo.ListIndex <> -1 Then
strSQL = strSQL & " and Project_Name = '" & ProgCombo.Column(0) & "'"
End If
If CSCICombo.ListIndex <> -1 Then
strSQL = strSQL & " and CSCI = '" & CSCICombo.Column(0) & "'"
End If
If CategCombo.ListIndex <> -1 Then
strSQL = strSQL & " and Category = '" & CategCombo.Column(0) & "'"
End If
======
Hope this helps.
Regards,
Michi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|