Using view to manage resource reservations - guaranteed valid/up-to-date after Refresh?

Hello,

I’m experiencing double bookings/going over max resource capacity in my resource reservation code. Each resource has max capacity, reservations have start and end timestamps. A view is used to lookup for existing reservations and to calculate if existing reservations + new one would exceed max capacity before accepting the new reservation. Can view be used for this kind of processing? Is it guaranteed to be 1:1 with documents after view.Refresh? It’s a one instance DB, multi-user web environment, relatively busy as well. I also try to lock the code (agent) that accesses the view while calculating available capacity (concurrent agents are allowed). Is there something silly I’m doing?

LockID = Createlock("RESERVATION_" & db.ReplicaID)



Do While True

	If Codelock(LockID) Then Exit Do Else Doevents

Loop



If IsValidReservation(reservation) Then ' refresh and access existing reservations view

	...

End If



On Error Resume Next

LockStatus = Codeunlock(LockID)

LockStatus = Destroylock(LockID)



Exit Sub

ErrHandle:

Call PrintError("SaveReservation/Initialize", Err, Error$, Erl, context)

On Error Resume Next

LockStatus = Codeunlock(LockID)

LockStatus = Destroylock(LockID)

Just trying to rule this out before trying alternative routes…

Thanks In Advance,

Jan