I have a field on my form which I want to display a message box when something is entered.
Private Sub BoI_AfterUpdate()
Box = Msgbox("Is the booking date at least 7 days before the hiring and no more than 8 weeks in advance? If so, click Yes, otherwise, click No. You can check the calender on the Open Form under the 'Miscellanous' tab to check the date. Thank you.", vbYesNo, "Validation")
If Box = vbYes Then Cancel = False
Else
Cancel = True
End If
End Sub
That's my code, but I get an error after I type something in that field (BoI).
"Compile error: Else without If" I have tried it with 'ElseIf Box = vbNo Then Cancel = True' but that also gives the same error.
What's wrong with it?
Thanks in advance.
Private Sub BoI_AfterUpdate()
Box = Msgbox("Is the booking date at least 7 days before the hiring and no more than 8 weeks in advance? If so, click Yes, otherwise, click No. You can check the calender on the Open Form under the 'Miscellanous' tab to check the date. Thank you.", vbYesNo, "Validation")
If Box = vbYes Then Cancel = False
Else
Cancel = True
End If
End Sub
That's my code, but I get an error after I type something in that field (BoI).
"Compile error: Else without If" I have tried it with 'ElseIf Box = vbNo Then Cancel = True' but that also gives the same error.
What's wrong with it?
Thanks in advance.

Last edited: