ChuckDrago
Active Member
- Joined
- Sep 7, 2007
- Messages
- 470
- Office Version
- 2010
- Platform
- Windows
Hi everyone,
We have an hourly reservation calendar where users reserve slots of time for their use of the corresponding conference room. Playing with fire, I always considered that two users going in at the same time was a rare event, so data contention and losses could be avoided. Wrong. A couple of last saves obliterated the reservation of the other users.
To avoid that, I am attempting a workbook containing a user form in which call buttons can be actioned to do the following:
1) If the Reservation file being called is in use, then a message advises the user to wait a few and try again.
2) If it is not in use, the Reservation file is instantiated.
The problem is how to safely close the calling workbook from within the open Reservation file, without upsetting the session.
This closure should be at the very beginning of the initialization code, prior to the user executing his reservation.
I tried the Workbooks.close statement but depending where it is positioned in the Workbooks_Open macro it does weird things, like stop the execution of the Reservation file, occasional catastrophic failures, etc.
Any suggestions will be very appreciated.
Chuck
PS: This is the Reservation Open macro:
<code/>
Private Sub Workbook_Open()
Application.EnableCancelKey = xlDisabled
Application.WindowState = xlMaximized
Sheets(MonthName(Month(Date))).Activate
Application.ScreenUpdating = False
Application.Goto Sheets(MonthName(Month(Date))).Range("A6"), True
Dim c As Integer
Dim r As Integer
Call UnprotectMonth
For c = 4 To 12 Step 2
For r = 10 To 46 Step 9
If Cells(r, c) = Day(Now) Then
Cells(r, c).Font.Color = RGB(255, 0, 0)
Else
Debug.Print Cells(r, c).Address
Cells(r, c).Font.Color = RGB(0, 0, 0)
End If
Next r
Next c
Call Initializer
Application.ScreenUpdating = True
Call ProtectMonth
End Sub
</Code>
We have an hourly reservation calendar where users reserve slots of time for their use of the corresponding conference room. Playing with fire, I always considered that two users going in at the same time was a rare event, so data contention and losses could be avoided. Wrong. A couple of last saves obliterated the reservation of the other users.
To avoid that, I am attempting a workbook containing a user form in which call buttons can be actioned to do the following:
1) If the Reservation file being called is in use, then a message advises the user to wait a few and try again.
2) If it is not in use, the Reservation file is instantiated.
The problem is how to safely close the calling workbook from within the open Reservation file, without upsetting the session.
This closure should be at the very beginning of the initialization code, prior to the user executing his reservation.
I tried the Workbooks.close statement but depending where it is positioned in the Workbooks_Open macro it does weird things, like stop the execution of the Reservation file, occasional catastrophic failures, etc.
Any suggestions will be very appreciated.
Chuck
PS: This is the Reservation Open macro:
<code/>
Private Sub Workbook_Open()
Application.EnableCancelKey = xlDisabled
Application.WindowState = xlMaximized
Sheets(MonthName(Month(Date))).Activate
Application.ScreenUpdating = False
Application.Goto Sheets(MonthName(Month(Date))).Range("A6"), True
Dim c As Integer
Dim r As Integer
Call UnprotectMonth
For c = 4 To 12 Step 2
For r = 10 To 46 Step 9
If Cells(r, c) = Day(Now) Then
Cells(r, c).Font.Color = RGB(255, 0, 0)
Else
Debug.Print Cells(r, c).Address
Cells(r, c).Font.Color = RGB(0, 0, 0)
End If
Next r
Next c
Call Initializer
Application.ScreenUpdating = True
Call ProtectMonth
End Sub
</Code>