I am attempting to create a Function for Access 2000 to compare quite a few date fields to decide whether a job is late or not. I have created the following function and am attempting to run from a Query using the fields in the Query to populate the variables. When I run the code, I get the Else with out If compile error. The code stops on the first ElseIf statement line. I used variant variables because the date fields could be empty.
Any clues as to what I am not doing correctly?
Thanks.
Dawn
Code:
Public Function Late(FSched As Variant, FStart As Variant, CSched As Variant, CStart As Variant, MSched As Variant, MStart As Variant, ESched As Variant, EStart As Variant, PSched As Variant, PStart As Variant) As String
'FSched = Factory Schedule Date
'FStart = Factory Actual Start Date
'CSched = Cutting Schedule Date
'CStart = Cutting Actual Start Date
'MSched = Material Schedule Date
'MStart = Material Actual Start
'ESched = Engineering Schedule Date
'EStart = Engineering Actual Start Date
'PSched = Purchasing Schedule Date
'PStart = Purchasing Actual Start Date
Dim CurrentDate As Date
Dim status As String
CurrentDate = Date
If (FSched < CurrentDate Or FSched < FStart) Then status = "Late"
ElseIf (CSched < CurrentDate Or CSched < CStart) Then status = "Late"
ElseIf (MSched < CurrentDate Or MSched < MStart) Then status = "Late"
ElseIf (ESched < CurrentDate Or ESched < EStart) Then status = "Late"
ElseIf (PSched < CurrentDate Or PSched < PStart) Then status = "Late"
Else
status = "OnTime"
End If
Late = status
End Function
Any clues as to what I am not doing correctly?
Thanks.
Dawn