Using InStr on form control

  • Thread starter Thread starter Veus
  • Start date Start date
V

Veus

Hi,

I have this bit of code:

Dim myText As Variant, i As Long

If Not IsNull(Me.mktAreaCombo) Or Me.mktAreaCombo = "" Then
If InStr(Me.mktAreaCombo, "...") > 0 Then
MsgBox "... Detected!"
myText = Split(Me.mktAreaCombo, "...")

For i = LBound(myText) To UBound(myText)
MsgBox myText(i)
Next i
Else
strWhere = strWhere & "([mktArea] = " &
Me.Controls("mktAreaCombo") & ") AND "
MsgBox "No ..."
End If
Exit Sub
End If

Im trying to check if "..." exists in what the user has entered in the
control called Me.mktAreaCombo

Even when i MsgBox out the control value it equals "1...2" (my
testing) however the InStr function always returns 0.

If i replace InStr(Me.mktAreaCombo, "...") with InStr("1...2", "...")
it works fine, however not when its reading it from a variable which
also equals "1...2"?

Am i missing something obvious?

Thanks
 
Veus said:
I have this bit of code:

Dim myText As Variant, i As Long

If Not IsNull(Me.mktAreaCombo) Or Me.mktAreaCombo = "" Then
If InStr(Me.mktAreaCombo, "...") > 0 Then
MsgBox "... Detected!"
myText = Split(Me.mktAreaCombo, "...")

For i = LBound(myText) To UBound(myText)
MsgBox myText(i)
Next i
Else
strWhere = strWhere & "([mktArea] = " &
Me.Controls("mktAreaCombo") & ") AND "
MsgBox "No ..."
End If
Exit Sub
End If

Im trying to check if "..." exists in what the user has entered in the
control called Me.mktAreaCombo

Even when i MsgBox out the control value it equals "1...2" (my
testing) however the InStr function always returns 0.

If i replace InStr(Me.mktAreaCombo, "...") with InStr("1...2", "...")
it works fine, however not when its reading it from a variable which
also equals "1...2"?


Add another MsgBox to display the value of the combo box. I
think you might find it is not 1...2
 
Veus said:
I have this bit of code:
Dim myText As Variant, i As Long
If Not IsNull(Me.mktAreaCombo) Or Me.mktAreaCombo = "" Then
If InStr(Me.mktAreaCombo, "...") > 0 Then
MsgBox "... Detected!"
myText = Split(Me.mktAreaCombo, "...")
For i = LBound(myText) To UBound(myText)
MsgBox myText(i)
Next i
Else
strWhere = strWhere & "([mktArea] = " &
Me.Controls("mktAreaCombo") & ") AND "
MsgBox "No ..."
End If
Exit Sub
End If
Im trying to check if "..." exists in what the user has entered in the
control called Me.mktAreaCombo
Even when i MsgBox out the control value it equals "1...2" (my
testing) however the InStr function always returns 0.
If i replace InStr(Me.mktAreaCombo, "...") with InStr("1...2", "...")
it works fine, however not when its reading it from a variable which
also equals "1...2"?

Add another MsgBox to display the value of the combo box. I
think you might find it is not 1...2


Nope, I added the MsgBox before:
MsgBox Me.mktAreaCombo.Value

However it prints out 1...2 but the InStr isnt true.
 
Veus said:
I have this bit of code:
Dim myText As Variant, i As Long
If Not IsNull(Me.mktAreaCombo) Or Me.mktAreaCombo = "" Then
If InStr(Me.mktAreaCombo, "...") > 0 Then
MsgBox "... Detected!"
myText = Split(Me.mktAreaCombo, "...")
For i = LBound(myText) To UBound(myText)
MsgBox myText(i)
Next i
Else
strWhere = strWhere & "([mktArea] = " &
Me.Controls("mktAreaCombo") & ") AND "
MsgBox "No ..."
End If
Exit Sub
End If
Im trying to check if "..." exists in what the user has entered in the
control called Me.mktAreaCombo
Even when i MsgBox out the control value it equals "1...2" (my
testing) however the InStr function always returns 0.
If i replace InStr(Me.mktAreaCombo, "...") with InStr("1...2", "...")
it works fine, however not when its reading it from a variable which
also equals "1...2"?
Add another MsgBox to display the value of the combo box. I
think you might find it is not 1...2

Nope, I added the MsgBox before:
MsgBox Me.mktAreaCombo.Value

However it prints out 1...2 but the InStr isnt true.

THis has been solved. It was infact AutoCorrect which was
automatically converting the three dots into the ellipsis symbol.
 
Veus said:
I have this bit of code: []
If InStr(Me.mktAreaCombo, "...") > 0 Then
MsgBox "... Detected!" []
Im trying to check if "..." exists in what the user has entered in the
control called Me.mktAreaCombo
Even when i MsgBox out the control value it equals "1...2" (my
testing) however the InStr function always returns 0.
[]
THis has been solved. It was infact AutoCorrect which was
automatically converting the three dots into the ellipsis symbol.


Excellent work! Tracking that down is not intuitive and
well worth remembering.
 
Back
Top