A small question (1 Viewer)

xMax

Registered User.
Local time
Today, 02:39
Joined
Aug 7, 2006
Messages
35
I am working on a laser tag database where I have to schedule laser tag games (each game is 15 minutes long or 30 minutes long).
There is a group who wants to play a 30 minute game but each entry is 15 minutes long. I can use Visual Basic 6 to check a table and see
if one 15 minute game is available but I cannot run a check to see if two consecutive 15 minute blocks are available. How do I
check to see if two consecutive 15-minute blocks are available?

A Sample of the Table:

Game ID Game Time Number of Players Type of Game

1 12:15 PM 8 Team Game
2 12:30 PM 6 Free For All
3 12:45 PM 6 Free For All
4 1:00 PM 12 Capture The Flag
 

WayneRyan

AWF VIP
Local time
Today, 07:39
Joined
Nov 19, 2002
Messages
7,122
XMAX,

Can you post the functional code for checking 1 block?

It shouldn't be too tough to modify it.

Wayne
 

xMax

Registered User.
Local time
Today, 02:39
Joined
Aug 7, 2006
Messages
35
Table Fields (tables named qryGameTimes - it shows all the available appointments for the laser tag games)

Game ID (Auto-Number) & Primary Key
Time (Date/Time) (all times that the arena is open - 10:00 AM to 12:00 AM)
Room (Number) (the two rooms that we have for laser tag)
Available (Yes/No) (is someone using the room at the time?)


A Sample Record would be like this:

Game ID: 1 Time: 12:30 PM Room: 2 Available: No

I first declare a variable and assume that the time requested is unavailable.

Dim available As Boolean

available = false

Then I declare the time requested.

Dim timerequested As Date

timerequested = 12:30 PM (information obtained by form)

Dim room as integer

room = 1 (room can either be 1 or 2 so we start with room)

Then I check to see if the Available field is checked by using a DLookUp Command:

available = DLookUp ("Available", "tblGameTimes", ["Time = timerequested" and Room = room"]

This checks to see if anyone is using room 1 at 12:30 PM.

Now, suppose room 1 is not available.

If available = False Then

room = 2

available = DLookUp ("Available, "tblGameTimes", [Time = timerequested" and Room = room"]

End If

Now suppose room 2 was available at 12:30, but another family ordered a 12:45 appointment. How do I check that?


Thanks.
 

WayneRyan

AWF VIP
Local time
Today, 07:39
Joined
Nov 19, 2002
Messages
7,122
xMax,

Get the count of rooms where:
"Room = 1" and
"Available = No" and
the requested time is within a half hour +/- the booking time.

Code:
available = DCount("[Available]", _
                   "tblGameTimes", 
                   "[Room] = " & Me.Room & " And " & _
                   "[Available] = 'No' And " & _
                   timerequested & " Not Between Time - 30 And Time + 30")

Notes:

1) I'm not sure, but you might need a function to get the Time +/- 30 minutes.

2) Time is a reserved word.

3) I'd have each booking represented by a Starting and Ending DateTime value.
That way, you can easily span dated and cope with variable length reservations.
Your check would then be if:

TimeRequested Between StartTime And EndTime <-- much simpler.

Wayne
 

WayneRyan

AWF VIP
Local time
Today, 07:39
Joined
Nov 19, 2002
Messages
7,122
xMax,

Forgot to add:

Your syntax was off in your DLookUp.

And I changed to a DCount, it doesn't return Nulls.

Wayne
 

Users who are viewing this thread

Top Bottom