what's wrong with this string compare check?

jguscs

Registered User.
Local time
Today, 15:52
Joined
Jun 23, 2003
Messages
148
If StrComp(Me!EPState, "New York") < 1 Then
Me!EPState = "NY"
End If
 
I see lots of potential problems there. What are you trying to achieve? If you're trying to see if the text entered into the textbox is "New York" then you can simply use
If Me!EPState="New York" Then

Most string comparisons in Access are case insensitive, so it will work whether EPState contains "New york", "new york", or even "NeW YorK".
 
What I'm trying to do is take the value of a control, compare it to a specific string, like "New York" and if the strings match (preferably not case-sensitive), change the value of the control to the state's abbreviation.
So you're saying this will work:

If Me!EPState="New York" Then
Me!EPState="NEY
End If

But I tried it, and it doesn't.
It gives me an error: Type Mismatch. and points to the first line.
 
Trust me, if EPState is a text field, or some other type of field where the bound column contains the text "New York" then the following should work:

If Me!EPState="New York" Then
  Me!EPState="NY"
End If


It works on my system. The error you're getting suggests that perhaps the field is storing data in a different format.
 

Users who are viewing this thread

Back
Top Bottom