Ok this seems like the simplest thing but it is not working in my code. I have tried everything but just can't figure out why my instr function is not finding my string when it is right there. Here is my code:
If Not rs1.EOF And Not IsNull(msub) Then
lpos = InStr(rs1!sub, msub)
If lpos = 0 Then
msub = msub & ", " & rs1!sub
End If
nqty = nqty + Nz(rs1!Farm_M_C_Qty, 0) + Nz(rs1!MTT_2pg_C, 0) + Nz(rs1!MTT_4pg_C, 0)
npostage = npostage + Nz(rs1!FARM_M_C_POSTAGE, 0) + Nz(rs1!MTT_2PG_POSTAGE, 0) + Nz(rs1!MTT_4PG_POSTAGE, 0)
End If
End If
The sub contains a 4 digit text number of the month and day of a date. EX: 0706. I am concantenating a field of subs but do not want to include the same sub twice. When it goes through the loop my first value is "0706", msub becomes "0706", the next time through it rs1!sub = "0707" so msub becomes "0706, 0707", the next time through rs1!sub = "0707" again. the instr function should return 6 for lpos and skip doing the f statement to concantenate msub but lpos returns 0 and I end up with "0706, 0707, 0707". I have tried defining a start position and I have tried defining it as binary and text but I keep getting 0 as the result like it never finds it in the string. EX: lpos = Instr(1, rs1!sub, msub, 1) still returns 0. What am i missing?