>Naiomi,
>
>Appoplogies I chopped about the example SQL and missed out a couple of rather relevent lines, should have been:
>
>* Move to Previous record
>cSQL = "SELECT TOP 1 * FROM "_
> & "(SELECT TOP 1 * FROM Master WHERE " _
> & "Id < '" & cLastId & "' " _
> & "ORDER BY Id DESC) curMaster "_
> & "UNION ALL "_
> & "SELECT * FROM "_
> & "(SELECT TOP 1 * FROM Archive WHERE " _
> & "Id < '" & cLastId & "' " _
> & "ORDER BY Id DESC) curArchive "_
> & "ORDER BY Id DESC"
>
>
>All the best,
I see, it's much better now, but you still don't need the first SELECT TOP 1 since you're selecting TOP 1 in the derived table. Or do you think it may return multiple records in case of the same ID? The current SQL looks ambigious to me.
Do you want to return just one the most recent record from either Master or Archive and thus you added select TOP 1 to the first select? Doesn't look right to me...
If it's not broken, fix it until it is.
My Blog