Help Building A String!

Moonshine

Registered User.
Local time
Today, 22:01
Joined
Jan 29, 2003
Messages
125
Hi, i need to build a string to go into a "IN" statement, im changing the .sql of the query in code, and then opening the updated query.

The in statement is built up from 5 Check boxes, depending on what box(s) you tick, the string will be of variable options.. These are my checkbox holding strings:

If Me.Check16 = True Then strB = "B" Else strB = ""
If Me.Check22 = True Then strF = "F" Else strF = ""
If Me.Check24 = True Then strW = "W" Else strW = ""
If Me.Check26 = True Then strO = "O" Else strO = ""
If Me.Check28 = True Then strAll = "B,F,W,O" Else strAll = ""

I then want to pass these to a holding str ("strIn") which i will then use in the qdf In statement. Depending on what boxes you tick, the strIn could be all 4, or 3 of the 4, or 1 of the 4... but i cant figure out how to building the string.

Eg:

If you ticked Check Boxes 16 and 24 the strIn would be ("B","W"). If you ticked only Check26 strIn would be ("O"). If you ticked Check24 and 26 strIn would be ("W","O"). If you ticked Check28, strIn would be ("B,F,W,O")

Please help!! :confused:
 
Sorted it, i didnt know you could have empty strings in a IN statement, that dont effect the outcome.

If Me.Check16 = True Then strB = """B""" Else strB = """"""
If Me.Check22 = True Then strF = """F""" Else strF = """"""
If Me.Check24 = True Then strW = """W""" Else strW = """"""
If Me.Check26 = True Then strO = """O""" Else strO = """"""
If Me.Check28 = True Then strAll = """B,F,W,O""" Else strAll = """"""

Which built the "In" statement like:

" HAVING ((([tbl Main].CouncilArea) In (" & strB & "," & strF & "," & strW & "," & strO & "))" & _

That worked perfectly :)
 

Users who are viewing this thread

Back
Top Bottom