Using InStr on form control

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
 
M

Marshall Barton

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
 
V

Veus

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.
 
V

Veus

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.
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top