Else without If error

AuroX7

Registered User.
Local time
Today, 09:05
Joined
Feb 22, 2006
Messages
44
When I enter text into my 'toe' string field, I get an error
Private Sub toe_AfterUpdate()
Dim toe As String
Dim ee As Boolean
Dim kip As String
Dim kip1 As String

If toe = "Play Group" Or "Guides & Brownies" Or "Cub Scouts" Or "Women's Institute" Or "Line Dancing" Then Me.ee = True And kip =
MsgBox("This is a Regular Booking. Please check the calender on the Welcome Form for the dates. Thank you")
Else
kip1 = MsgBox("This is an Occasional Booking.", vbOKOnly, "Occasional Booking")
End If

End Sub

That's my code, but I get en error saying 'Compile error: Else without If'
If someone could help me I'd greatly appreciate it. Time is running out.
 
There's several questionable things going on in your code but with the the if error I would say you need to form it a little better:

Code:
If me!toe = "Play Group" Or "Guides & Brownies" Or "Cub Scouts" Or "Women's Institute" Or "Line Dancing" Then 
    Me.ee = True
    kip = MsgBox("This is a Regular Booking. Please check the calender on the Welcome Form for the dates. Thank you")
Else
    kip1 = MsgBox("This is an Occasional Booking.", vbOKOnly, "Occasional Booking")
End If
 
It's still happening. :(:( There's a type mismatch now.
 
Last edited:
Ok... So one of the other problems is the way you're checking the conditions. I think the following is the proper way to do this 'if':

Code:
If me!toe = "Play Group" Or me!toe =  "Guides & Brownies" Or me!toe = "Cub Scouts" Or me!toe = "Women's Institute" Or me!toe = "Line Dancing" Then 
    Me.ee = True
    kip = MsgBox("This is a Regular Booking. Please check the calender on the Welcome Form for the dates. Thank you")
Else
    kip1 = MsgBox("This is an Occasional Booking.", vbOKOnly, "Occasional Booking")
End If
And just to keep all of that a little more readable, you could do:

Code:
If me!toe = "Play Group" Or _
   me!toe =  "Guides & Brownies" Or _
   me!toe = "Cub Scouts" Or _
   me!toe = "Women's Institute" Or _
   me!toe = "Line Dancing" Then 
        Me.ee = True
        kip = MsgBox("This is a Regular Booking. Please check the calender on the Welcome Form for the dates. Thank you")
Else
        kip1 = MsgBox("This is an Occasional Booking.", vbOKOnly, "Occasional Booking")
End If
 
Thank You!

Thank you so so so so so so so so much. :D:D:D:D:D Have a good day! :):D:):D
 

Users who are viewing this thread

Back
Top Bottom