I am trying to run a Stored MS-access Query from excel using VBA. I have created a generic function to preform this task (using ADODB). I can get results with or without parameters. 

However when I try to run a stored Query that references an Access vba module, excel barfs a runtime error "undefined function MissCat" (which is the name of the custom function the stored query uses).

I would have expected this to work as access knows the definition of the function, but now I get the feeling the ADODB interface is trying to interperet the SQL in the stored query without the aid of the VBA module i've created in access.

I am jumping through these hoops as most of my users do not have access installed on their machines. 

Is it possible for me to use the stored query as is (changing the query interface, perhaps)? or is the path of least resistance changing the query such that it doesn't need the custom function (as you can see below it is quite simple, I've used it as a crutch because I don't know SQL very well)

here is the function

```
Function MissCat(ProShip As Date, TargetDate As Date) As String

If TargetDate >= ProShip Then
    MissCat = "Meets target"
    Exit Function
End If

If TargetDate < Date Then
    MissCat = "Unrecoverable"
    Exit Function
End If

Select Case ProShip - TargetDate
    Case 1 To 6
        MissCat = "Less than one week"
    Case 7 To 14
        MissCat = "1-2 Weeks"
    Case Else
        MissCat = "Greater than 2 Weeks"
End Select
End Function

```

and here is the SQL

```
TRANSFORM Count(Shipset.ID) AS CountOfID
SELECT Calendar.[Week Of]
FROM Calendar INNER JOIN Shipset ON Calendar.DateSerial = Shipset.ShipDate
WHERE (((Calendar.[Week Of])>Date()-(13*7)) AND ((Shipset.ShipDate) Is Not Null) AND   ((Shipset.ReqOut)=False) AND ((Shipset.TwoTier)=False))
GROUP BY Calendar.[Week Of]
ORDER BY IIf(MissCat([Shipset]![ShipDate],[Shipset]![TargetDate])="Meets Target","Meets Target","Hit") DESC 
PIVOT IIf(MissCat([Shipset]![ShipDate],[Shipset]![TargetDate])="Meets Target","Meets Target","Hit");

```

thanks,