The first problem is the IIF() statements is incorrect.
Code:
IIf(cmbo_query_categorization = "non standard", Me!date_received = WorkdaysTest() + 5, Me!date_received = WorkdaysTest() + 2)
You cannot have the equals sign in the clause - the result returned is the result of comparing "Me!date_received" with "WorkdaysTest() + 5" (a boolean result - TRUE or FALSE).
The second problem is that the parameters for the "WorkdaysTest" function are missing. You need to have the "StartDate" and "EndDate"
Is would look something like
Code:
IIf(cmbo_query_categorization = "non standard", Me!date_received + WorkdaysTest(Me!date_received,Me!date_received+5) , Me!date_received + WorkdaysTest(Me!date_received,Me!date_received+2))
But I don't think the workdays function is what you want.
Now they asked me to skip the weekends. Now it needs to calculate only working days.
If I understand correctly, if "cmbo_query_categorization" = "non standard", you have "Me!date_received" plus 5 days for some action to happen.
If "Me!date_received" plus 5 days falls on a weekend, you should advance the date to the next weekday (Monday). So you need to determine if "Me!date_received" plus 5 days falls on a Saturday or Sunday, not determine the number of week days between two dates.
Paste the following code into a standard module
Code:
Public Function SkipWeekends(pDate As Date) As Integer
' Debug.Print Weekday(pDate)
Select Case Weekday(pDate)
Case 1 'Sunday - add 1 day
SkipWeekends = 1
Case 7 'Saturday - add 2 days
SkipWeekends = 2
Case Else 'weekday - add 0 days
SkipWeekends = 0
End Select
End Function
Then use
Code:
Private Sub cmbo_query_categorization_AfterUpdate()
Me.expected_resolution_time = IIf(Me.cmbo_query_categorization = "non standard", CDate(Me!date_received) + 5 + SkipWeekends(CDate(Me!date_received) + 5), CDate(Me!date_received) + 2 + SkipWeekends(CDate(Me!date_received) + 2))
End Sub
I had to add the CDate() function because I was using unbound text boxes to test.
NOTE: you don't have to add ".Value" because the value property is the default property.