I'm trying to make a piece of code work
the idea is that if the years don't match (specific dates don't matter) then it won't let the user enter the date - however I don't want the alert to appear when the user clears the textbox for the bookingdate (if they change the year - it automatically has an action to null the bookingdate field)
code so far is:
Code:
Private Sub BookingDate_AfterUpdate()
Dim strYear As String
Dim strBooking As String
strYear = Nz(Year(Me.BookingYear.Column(1)), "no")
strBooking = Nz(Year(Me.BookingDate.Value), "") ' I get an error if I don't assign nz() to this
If strYear <> strBooking And IsNull(strBooking) Then
'do no task
ElseIf strYear <> strBooking And Not IsNull(strBooking) Then
MsgBox "You have selected a date that is not within the year, please select a correct booking date or change the year"
Me.BookingDate = Null
End If
End Sub
so um yeah, how do I get around something like this, the proper way.