Compile error

  • Thread starter Thread starter Nick T
  • Start date Start date
N

Nick T

Hi,

I keep getting a compile error: "Block If without End If".

Can i put more than one If statement in the code of any one cmd button?

Suggestions greatly appreciated.

Thanks
 
hi Nick,


Nick said:
I keep getting a compile error: "Block If without End If".
So simply add an End If at the right position (line) of your code.
Can i put more than one If statement in the code of any one cmd button? Yes.

Suggestions greatly appreciated.
Post the code. Otherwise your problem can only be guessed...



mfG
--> stefan <--
 
You sure can and that's probably where the error comes from. It's handy
practice to write the end if statement directly after you start the if. That
way you cannot forget the end if at the end

so:

if

end if

It might be the error that you started an if and then after the then started
with an enter and started to evaluate and forgot the end if...

so many options and ways to forget the end if ;-)
 
Hi,

I keep getting a compile error: "Block If without End If".

Can i put more than one If statement in the code of any one cmd button?

Sure. Each IF must have its matching END IF unless you use the single line
syntax such as

IF Err.Number = 3105 Then GoTo Proc_Exit

You can either have If-End If blocks such as

If Condition1 Then
<do something for condition 1>
End If
If Condition2 Then
<do something for condition 2>
End If

or they can be nested:

If Condition1 Then
If Subcondition Then
<do something for this subcondition>
Else
<do something if the subcondition is untrue>
End If ' end the subcondition if
End If ' end the Condition1 if
Suggestions greatly appreciated.

If you ask a question about an error in your code... it's polite to post the
code.
 
Back
Top