Now this is bad....
The Weird and The Wonderful
21
Posts
18
Posters
0
Views
1
Watching
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then