G
Guest
I have an Iif statement that is too long to put in a query so I am trying to
write a function in VBA and call it in the query expression instead. The
following is the function I’m trying to write (scaled down). It’s not
working at all; each row gives a date of 12/30/1899, which is not correct.
Can someone please tell me what I’m doing wrong? Thanks much.
Query expression: BP: MCSParent()
All the fields are date/time in the underlying table
Function MCSParent() As Date
Dim MCSOne As Date
Dim PartAMCS As Date
Dim PartBMCS As Date
Dim PartCMCS As Date
If MCSOne < PartAMCS Then
MCSParent = MCSOne
Else MCSParent = PartAMCS
End Function
When I type End If, I get an error. The IIf statement I’m trying to
duplicate is:
Iif [mcsOne] < [PartAMCS] or [mcsOne] < [PartBMCS] or [mcsOne] < {PartCMCS],
[mcsOne], Iif [PartAMCS] < [PartBMCS] or [PartAMCS] < [PartCMCS], [PartAMCS],
Iif [PartBMCS] < [PartCMCS], [PartBMCS], [PartCMCS])))
write a function in VBA and call it in the query expression instead. The
following is the function I’m trying to write (scaled down). It’s not
working at all; each row gives a date of 12/30/1899, which is not correct.
Can someone please tell me what I’m doing wrong? Thanks much.
Query expression: BP: MCSParent()
All the fields are date/time in the underlying table
Function MCSParent() As Date
Dim MCSOne As Date
Dim PartAMCS As Date
Dim PartBMCS As Date
Dim PartCMCS As Date
If MCSOne < PartAMCS Then
MCSParent = MCSOne
Else MCSParent = PartAMCS
End Function
When I type End If, I get an error. The IIf statement I’m trying to
duplicate is:
Iif [mcsOne] < [PartAMCS] or [mcsOne] < [PartBMCS] or [mcsOne] < {PartCMCS],
[mcsOne], Iif [PartAMCS] < [PartBMCS] or [PartAMCS] < [PartCMCS], [PartAMCS],
Iif [PartBMCS] < [PartCMCS], [PartBMCS], [PartCMCS])))