Using a for next loop to assemble a search string from split array
Posted on 2011-03-04
Hi all -- I'm new (back) to EE and need some help. I have a textbox on a form (TxtAttribute1) and I want to pull the string out of it and then do a split based on ;. That part seems to be fine. However, I have a search string (strWhere) to which I want to add each member of the array, along with the appropriate filtering language for each individual member. There are other boxes that add similar filtering language to strWhere (date ranges, attributes, etc) but which aren't lited here. The code below doesn't cause any errors but it only returns the first member of the array (nothing else). I've tried everything I can think of with the loop and am at wit's end. so this is max points. I'm sure it's something small, so help me out, y'all....!
Dim strWhere As String
strWhere = "1=1"
Dim i As Integer
Dim sparts() As String
If Nz(Me.TxtAttribute1) <> "" Then
sparts = Split(Me.TxtAttribute1, ";")
For i = LBound(sparts) To UBound(sparts)
strWhere = strWhere & " AND " & "BaseDataTableItemA.TxtAttribute1 Like '*" & sparts(i) & "*'"