Compile Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top