So I am trying to create a string array in microsoft access visual basic that will hold a certain number of States names. I also will have a form that will allow people to do data entry on. If they select a one of the states that happen to be in this array from a drop down list of ALL the states on the form, I want it to activate a msgbox that will popup and tell them a specific message.
So far all I've been able to find is code somewhat like this:
Dim State(3) As String
Dim Str As String
State(0) = "California"
State(1) = "Florida"
State(2) = "New Hampshire"
State(3) = "Illinois"
For Each Str In State
If State.Contains(Str) Then
MsgBox("Found " & Str & " at index " & State.IndexOf(Str))
End If
Next
Basically what my main issue is is that right now the code has the equivalent of if the entered data = this state or if it = this state or if it = this state etc. all with inline continuations, then do the msg box. The problem that gives is that you can only effectively have 24 continuations in access vb, and I now have over 25 states that I need to check for. Also, I inherited this mess of code and am unable to completely trash it and rewrite so I figured using a string array might be a workable fix.