User-Defined Fx in Query not Working

  • Thread starter Thread starter BarryC
  • Start date Start date
B

BarryC

I have a user-defined function in a query. The function is defined in a
module. It is as follows:

Option Compare Database

Global uidUser As Double

Public Function UserSession() As Double

UserSession = uidUser

End Function

The query looks like this:

SELECT ShiftTable1.Week, Sum(ShiftTable1.AvgOfUtilization1) AS
SumOfAvgOfUtilization1 FROM ShiftTable1
WHERE (((ShiftTable1.UID)=UserSession()))
GROUP BY ShiftTable1.Week;

When executed, the query returns no rows, even though there are
matching rows in the queried table and the debug window shows that
uidUser and UserSession are populated with the correct value.

When the actual value of UserSession is copied from the debug window
and used in the query, the query correctly returns rows.

How do I fix this?
 
Exactly what datatype is UID in the table?

Double sounds like an unusual choice for an ID, since it's prone to
round-off errors that can result in apparently equal numbers not actually
being treated as equal.
 
Douglas said:
Exactly what datatype is UID in the table?

Double sounds like an unusual choice for an ID, since it's prone to
round-off errors that can result in apparently equal numbers not actually
being treated as equal.

It is Double.

Do you suggest Long?

I wanted to use GUID, but that type is unavailable.
 
Back
Top