vba End If without block If - error when Compiling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • georgekos
    New Member
    • Jul 2014
    • 1

    #1

    vba End If without block If - error when Compiling

    my Code:
    Code:
    If (RaceHorsesIX("Track") = "APX" Or _
        RaceHorsesIX("Track") = "ALB" Or _
        RaceHorsesIX("Track") = "AQU" Or _
        RaceHorsesIX("Track") = "BEL" Or _
        RaceHorsesIX("Track") = "BEU" Or _
        RaceHorsesIX("Track") = "CBY" Or _
        RaceHorsesIX("Track") = "CDX" Or _
        RaceHorsesIX("Track") = "CTX" Or _
        RaceHorsesIX("Track") = "DED" Or _
        RaceHorsesIX("Track") = "EMD" Or _
        RaceHorsesIX("Track") = "EVD" Or _
        RaceHorsesIX("Track") = "FLX") Then _
            GoTo TrackOK
    End If
    HELP!!!
    Last edited by NeoPa; Jul 26 '14, 09:32 PM. Reason: Added tags.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    one of two things:

    Either get rid of the line continuation after "Then" or just delete "END IF"

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      YUCK, what a hard code to maintain.
      IMHO:
      If you have to hard code this, then the
      Select...Case statement would be better:
      Code:
      Select UCASE(RaceHorsesIX("Track"))
         Case "APX","ALB", "AQU", "BEL" ...
            your code here
         case else
            your code here
      end select
      Easier to read and IMHO maintain.
      -
      Better yet, place these tracks in a table.
      Then open a recordset on the table with the WHERE clause set to pull the one record. Then check to see if there are any records in the set.
      Then as you add "Tracks" you do not need to re-code the application at all. (^_^)

      (also as of late... the GOTO statment isn't considered best practice anymore prefered is to call another module or function; however, I'm old school so it doesn't bother me so long as the code is readable and maintainable. (^_^) )
      Last edited by zmbd; Jul 29 '14, 05:02 PM. Reason: [z{stupid tab key}]

      Comment

      Working...