Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2011

    Unanswered: Multiple If Then Statements

    Attached is an example jpg of what I'm trying to accomplish. I have several If and ElseIf statements under a single Sub Form_Current().

    The actual code in my database has many more iterations, but the basic gist is that when "Yes" is selected in varied instances, other controls are either visible or not visible.

    I keep getting a "Compile Error: Block If without End If" message but my code clearly ends with...

    End If
    End Sub

    What am I missing? Do I need an "End If" after each "IF Else IF"? Am I trying to do too much?
    Attached Thumbnails Attached Thumbnails IfThenCode.JPG  

  2. #2
    Join Date
    Mar 2009
    You do need to close each block of if statements with an end if.

    Question - Is it supposed to be If then ElseIf all the way to the end because you have Ifs inbetween ElseIfs?

    If you post your code I could show you how to correct it.


  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    As SIndho says you need to terminate each if then, else block with an end if
    See A

    assuming that OFHY and SMD can only have two values "Yes" or "NO", there is no need for the elseif statement.
    See B

    of course if you do need a 3rd option then your elseif is fien.
    Attached Thumbnails Attached Thumbnails bradreynolds.png  
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts