I am developing an Access "project" (.adp) as a front-end to data in a SQL Server 2005 Express database.
In the Access Form that allows employees to clock-in and clock-out of work, I want to control the "events" the employees are recording based on what they have already recorded that day. Specifically, if the last event they recorded was either a "start of a break" or an "end of a break", then I shouldn't allow them to immediately record the same event again.
I am using a SQL Server Stored Procedure to do this and am trying to discover if the last recorded event is the same as the new one they are trying to record.
Basically, I need to know how to check if the results of a "Top 1", single column SELECT query is a particular value. My various attempts (example attached) produce an "Incorrect syntax near '='" error message when I try to save the Stored procedure.
Can anyone show me how this should be written?
Many thanks. Colin.
SET @paramAlreadyUsedBoolean = ISNULL ((SELECT TOP 1 ISNULL (ClockInEvent_Event, '')
WHERE (ClockInEvent_Operator = @paramOperator)
AND (CONVERT (varchar(12), ClockInEvent_DateTime, 103) = CONVERT (varchar(12), @paramDate, 103))
ORDER BY ClockInEvent_DateTime DESC), '') = @paramEvent