I have two tables that have a one-to-many relationship. Table 1 has staff ID info and table 2 has staff leave of absence info.
I have a search form that the user can search using staff id or staff name. The search form opens the LeaveInput form which contains the LeaveRecord subform.
When the subform loads, it calls a procedure that is suppose to calculate the number of days between two dates that are fields on the subform.
If the LeaveInput form opens to a staff without any data in the LeaveRecord subform, I receive an error message that says, "Run time error: 94 Invalid use of null".
My sub procedure looks like this:
Private Sub Form_Load()
If Me.LeaveBeginDate = Null Or Me.LeaveEndDate = Null Then
Exit Sub
End If
If Me.LeaveEndDate > Date Then
Me.CurrentDays.Value = CInt(CalculateDays(Me.LeaveBeginDate, Date))
Else
Me.CurrentDays.Value = CInt(CalculateDays(Me.LeaveBeginDate, Me.LeaveEndDate))
End If
End Sub
It appears that I'm getting the error message because the Me.LeaveBeginDate and Me.LeaveEndDate are null. But when that happens I want form load event to exit the sub procedure.
I would appreciate any suggestions.
Thanks.
I have a search form that the user can search using staff id or staff name. The search form opens the LeaveInput form which contains the LeaveRecord subform.
When the subform loads, it calls a procedure that is suppose to calculate the number of days between two dates that are fields on the subform.
If the LeaveInput form opens to a staff without any data in the LeaveRecord subform, I receive an error message that says, "Run time error: 94 Invalid use of null".
My sub procedure looks like this:
Private Sub Form_Load()
If Me.LeaveBeginDate = Null Or Me.LeaveEndDate = Null Then
Exit Sub
End If
If Me.LeaveEndDate > Date Then
Me.CurrentDays.Value = CInt(CalculateDays(Me.LeaveBeginDate, Date))
Else
Me.CurrentDays.Value = CInt(CalculateDays(Me.LeaveBeginDate, Me.LeaveEndDate))
End If
End Sub
It appears that I'm getting the error message because the Me.LeaveBeginDate and Me.LeaveEndDate are null. But when that happens I want form load event to exit the sub procedure.
I would appreciate any suggestions.
Thanks.