Compile Error

P

Phil

I have a problem when compiling my database the code that has a problem is

Private Sub Combo18_Change()

If [SessionID] = 14 Then [Combo22] = 2
Else: [Combo22] = 1
End If

End Sub

it says else without If, I have tried splitting it into two if statements
and then get End If without If, has anybody any suggestions

thanks

Phil
 
K

Keith Wilby

Phil said:
I have a problem when compiling my database the code that has a problem is

Private Sub Combo18_Change()

If [SessionID] = 14 Then [Combo22] = 2
Else: [Combo22] = 1
End If

End Sub

it says else without If, I have tried splitting it into two if statements
and then get End If without If, has anybody any suggestions

thanks

Phil

This is an example of the syntax you need:

If SomeCondition = Something Then
Do something
Else
Do something else
End If

Keith
www.keithwilby.com
 
M

missinglinq via AccessMonster.com

Keith's exactly right! You can use

If [SessionID] = 14 Then [Combo22] = 2

by itself with everything on one line AND without a corresponding End If,
but if you want to use an Else you have to move what follows Then onto the
next line AND use the End If
 
P

Phil

Thank you both, I changed changed them to the next line and compile completed

tahnks

PHil
 
Top