I'm returning an Integer from a VBA function in a global module to a query in Access 2000. That's fine. But as soon as I try to give the returning Integer a criteria like >0 or <>0, the resulting DataSheet produces the results of the query (judging from the first 20 or so rows, successfully) then an error message box saying that there is a data type mismatch. As soon as I OK the message box, Access redraws the datasheet with all errors. I've tried returning a Variant from the function but still had the same problem.

I've tried a search on this forum and a few Access and VB books but can't find an answer. Any help? Thanks.

The relevant portion of the SQL WHERE clause is
((CalcMaterial([TicketDetail].[Description]))<>0)

CalcMaterial is the VB function
Public Function CalcMaterial(strDescription As String) As Integer

As I said, the query has no problem with the returned value as long as there is no criteria against it.

Steve