Including Script Module in Query

So I have a label that gets its value from a query:

SELECT sum(amount) 
FROM tblwaste
WHERE plant = 'Frederick' and mdate > '20140731' and computer = 'frwastecol01'

The problem is that I would like to only select values from the previous shift. To do this, I wrote a script module called “FindShiftStartTime”. Is there any way I can call this script module from my query?

It may be possible, but to make everything a bit cleaner, maybe you could just create a scripting function that also runs the query, and try to bind the label to a [tt]runScript(…)[/tt] function that calls it?

Otherwise, I’d probably create a custom property on the label (or somewhere else, if this shift is needed in multiple places) called “ShiftId” or whatever, and bind that to a runScript that calls the function, and then reference that property inside of the query.

Regards,