Hi all,
I have a form with two option buttons (RentCharge and OtherCharge). I have code that clears OtherCharge when RentCharge is selected and vice versa.
When I click the save button on the form, I have code that runs a series of checks - below.
Unfortunately, I get the Block End without End If error and cannot find where I am going wrong.
Any advice would be very much appreciated.
I have a form with two option buttons (RentCharge and OtherCharge). I have code that clears OtherCharge when RentCharge is selected and vice versa.
When I click the save button on the form, I have code that runs a series of checks - below.
Unfortunately, I get the Block End without End If error and cannot find where I am going wrong.
Any advice would be very much appreciated.
Code:
Private Sub cmdSaveRentCharge_Click()
If RentCharge = True Then
If IsNull(StartDate) Then
msgbox "Please enter a start date.", vbOKOnly, "Weekly Rent Charge"
StartDate.SetFocus
ElseIf IsNull(FinishDate) Then
msgbox "Please enter a finish date.", vbOKOnly, "Weekly Rent Charge"
FinishDate.SetFocus
ElseIf StartDate > FinishDate Then
msgbox "Please check the dates - the start date must be on or before the finish date.", vbOKOnly, "Weekly Rent Charge"
StartDate.SetFocus
ElseIf IsNull(Amount) Then
msgbox "Please enter an amount.", vbOKOnly, "Weekly Rent Charge"
Amount.SetFocus
Me.RentCharge.Enabled = False
Me.RentCharge.Locked = True
Me.OtherCharge.Enabled = False
Me.OtherCharge.Locked = True
Me.StartDate.Enabled = False
Me.StartDate.Locked = True
Me.FinishDate.Enabled = False
Me.FinishDate.Locked = True
Me.Amount.Enabled = False
Me.Amount.Locked = True
Me.Notes.Enabled = False
Me.Notes.Locked = True
Me.cmdEditRentCharge.Enabled = True
Me.cmdSaveRentCharge.Enabled = False
Me.cmdClose.Enabled = True
Else
If IsNull(StartDate) Then
msgbox "Please enter the date the expense was incurred.", vbOKOnly, "Weekly Rent Charge"
StartDate.SetFocus
ElseIf IsNull(Amount) Then
msgbox "Please enter the expense amount.", vbOKOnly, "Weekly Rent Charge"
Amount.SetFocus
ElseIf IsNull(Notes) Then
msgbox "Please enter an expense description.", vbOKOnly, "Weekly Rent Charge"
Notes.SetFocus
Me.RentCharge.Enabled = False
Me.RentCharge.Locked = True
Me.OtherCharge.Enabled = False
Me.OtherCharge.Locked = True
Me.StartDate.Enabled = False
Me.StartDate.Locked = True
Me.FinishDate.Enabled = False
Me.FinishDate.Locked = True
Me.Amount.Enabled = False
Me.Amount.Locked = True
Me.Notes.Enabled = False
Me.Notes.Locked = True
Me.cmdEditRentCharge.Enabled = True
Me.cmdSaveRentCharge.Enabled = False
Me.cmdClose.Enabled = True
End If
End If
End Sub