title: "Data type mismatch in criteria expression." error in ms access, i did all the troubleshooting suggested
body: <p>i get the error "Data type mismatch in criteria expression." in a query.</p>
  
  <p>Like this the query works perfectly</p>
  
  <pre><code>WorkingDays([ORDER_NOTIFICATION_DATE],[OP_DISTRIBUTION_DATE]) AS
  BOOKING_DAYS, IIf([BOOKING_DAYS]&gt;8,"IS LATE","ON TIME") AS BOOKING_DELAYED
  FROM JOB INNER JOIN [ORDER] ON JOB.[JOB_ID] = ORDER.[JOB_ID]
  WHERE (((ORDER.ORDER_NOTIFICATION_DATE) Is Not Null) AND
  ((ORDER.OP_DISTRIBUTION_DATE) Is Not Null));
  </code></pre>
  
  <p>when i try to put another criteria it shows me the error:</p>
  
  <pre><code>WorkingDays([ORDER.ORDER_NOTIFICATION_DATE],[ORDER.OP_DISTRIBUTION_DATE]) AS 
  BOOKING_DAYS, IIf([BOOKING_DAYS]&gt;8,"IS LATE","ON TIME") AS BOOKING_DELAYED
  FROM JOB INNER JOIN [ORDER] ON JOB.[JOB_ID] = ORDER.[JOB_ID]
  WHERE (((ORDER.ORDER_NOTIFICATION_DATE) Is Not Null) AND 
  ((ORDER.OP_DISTRIBUTION_DATE) Is Not Null) AND
  ((WorkingDays([ORDER.ORDER_NOTIFICATION_DATE],
  [ORDER.OP_DISTRIBUTION_DATE]))&gt;8));
  </code></pre>
  
  <p>WorkingDays returns an integer, i tried most of the solutions proposed in other posts.</p>
  
  <p>this is WorkingDays:</p>
  
  <pre><code>Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
  '....................................................................
  ' Name:     WorkingDays
  ' Inputs:   StartDate As Date
  '   EndDate As Date
  ' Returns: Integer
  ' Author: Arvin Meyer
  ' Date:     February 19, 1997
  ' Comment: Accepts two dates and returns the number of weekdays between them
  ' Note that this function does not account for holidays.
  '....................................................................
  On Error GoTo Err_WorkingDays
  
  Dim intCount As Integer
  
  
  
  intCount = 0
  Do While StartDate &lt;= EndDate
  'Make the above &lt; and not &lt;= to not count the EndDate
  
  Select Case Weekday(StartDate)
  Case Is = 1, 7
  intCount = intCount
  Case Is = 2, 3, 4, 5, 6
  intCount = intCount + 1
  End Select
  StartDate = StartDate + 1  
  Loop
  WorkingDays = intCount
  
  Exit_WorkingDays:
  Exit Function
  
  Err_WorkingDays:
  Select Case Err
  
  Case Else
  MsgBox Err.Description
  Resume Exit_WorkingDays
  End Select
  
  End Function
  </code></pre>