473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Equipment booking and time range

121 100+
Hi,

I have an equipment booking form that a user is able to book a piece of equipment on a selected date and time. I have written code to prevent the user being able to book the piece of equipment if it has already been booked by a different user on the same date/time.

I want to display in a time grid format when that piece of equipment is booked. I currently have 16 green coloured boxes on my form each representing an hour's time interval so box 1 is 09:00 - 10:00 and so on. If the selected piece of equipment is booked on that day for a given time interval for example 12:00 - 15:00 I want to change the colour of the box's that represent 12:00 - 13:00 13:00 - 14:00 and 14:00 to 15:00 to red (which represents the equipment is already booked)

I currently have code that gives me a start and end time for the booking which enables me to change the start and end time box's to red as follows.Just cant think of a way to change the boxes in between

Expand|Select|Wrap|Line Numbers
  1. If BkdStartTimeID = #12:00:00 PM# Then
  2.  
  3. [Forms]![F_EquipBooking].[SF_EquipBooking]![Box12].BackColor = lngRed
  4.  
  5. If BkdEndTimeID = #3:00:00 PM# Then
  6.  
  7. [Forms]![F_EquipBooking].[SF_EquipBooking]![Box15].BackColor = lngRed
I hope my ramblings make sense any help is much appreciated

Regards Phill
May 5 '08 #1
7 2035
nico5038
3,080 Expert 2GB
Hi,

I have an equipment booking form that a user is able to book a piece of equipment on a selected date and time. I have written code to prevent the user being able to book the piece of equipment if it has already been booked by a different user on the same date/time.

I want to display in a time grid format when that piece of equipment is booked. I currently have 16 green coloured boxes on my form each representing an hour's time interval so box 1 is 09:00 - 10:00 and so on. If the selected piece of equipment is booked on that day for a given time interval for example 12:00 - 15:00 I want to change the colour of the box's that represent 12:00 - 13:00 13:00 - 14:00 and 14:00 to 15:00 to red (which represents the equipment is already booked)

I currently have code that gives me a start and end time for the booking which enables me to change the start and end time box's to red as follows.Just cant think of a way to change the boxes in between

Expand|Select|Wrap|Line Numbers
  1. If BkdStartTimeID = #12:00:00 PM# Then
  2.  
  3. [Forms]![F_EquipBooking].[SF_EquipBooking]![Box12].BackColor = lngRed
  4.  
  5. If BkdEndTimeID = #3:00:00 PM# Then
  6.  
  7. [Forms]![F_EquipBooking].[SF_EquipBooking]![Box15].BackColor = lngRed
I hope my ramblings make sense any help is much appreciated

Regards Phill
Good thing to try to make the time visible in this way.
I would use the Box name to manipulate the boxes in a loop.
You already use 12, 13, 14, 15, etc as the box name so a loop like:
Expand|Select|Wrap|Line Numbers
  1. intStart = format(BkdStartTimeID,"hh")
  2. intEnd = format(BkdEndTimeID ,"hh")
  3. WHILE intStart <= intEnd
  4.    Me.fields("Box" & format(intStart,"00").Backcolor = vbRed
  5.    intStart = intStart + 1
  6. WEND
  7.  
Just make sure all boxes are there and that the BkdEndTimeID has a value.

Getting the idea ?

Nic;o)
May 5 '08 #2
phill86
121 100+
Good thing to try to make the time visible in this way.
I would use the Box name to manipulate the boxes in a loop.
You already use 12, 13, 14, 15, etc as the box name so a loop like:
Expand|Select|Wrap|Line Numbers
  1. intStart = format(BkdStartTimeID,"hh")
  2. intEnd = format(BkdEndTimeID ,"hh")
  3. WHILE intStart <= intEnd
  4.    Me.fields("Box" & format(intStart,"00").Backcolor = vbRed
  5.    intStart = intStart + 1
  6. WEND
Just make sure all boxes are there and that the BkdEndTimeID has a value.

Getting the idea ?

Nic;o)
Hi Nic

Thanks for your help....

I can get it working to an extent if i include this line i get the folloing error message...

Compile error

Invalid use of me keyword
Expand|Select|Wrap|Line Numbers
  1. Me.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
So i changed it to the following and when it runs this line it just ends the function. The code is within a module in a function by the way..
Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
Regards Phill
May 5 '08 #3
nico5038
3,080 Expert 2GB
Hi Nic

Thanks for your help....

I can get it working to an extent if i include this line i get the folloing error message...

Compile error

Invalid use of me keyword

Me.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)

So i changed it to the following and when it runs this line it just ends the function. The code is within a module in a function by the way..

Forms![F_EquipBooking]![SF_EquipBooking].Fields ("Box" & Format(intstart, "00").BackColor = vbRed)

Regards Phill
Hi Phill,

Sorry my error, I assumed the code to be part of the form.
Just would have thought you would need to use:
Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].form.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
as Access requires an extra "form reference".

Nic;o)
May 5 '08 #4
NeoPa
32,556 Expert Mod 16PB
...
Expand|Select|Wrap|Line Numbers
  1. Me.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
...
The second closing parenthesis should be immediately after the first (before .BackColor).
Expand|Select|Wrap|Line Numbers
  1. Me.Fields("Box" & Format(intstart, "00")).BackColor = vbRed
May 5 '08 #5
phill86
121 100+
Hi Phill,

Sorry my error, I assumed the code to be part of the form.
Just would have thought you would need to use:
Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].form.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
as Access requires an extra "form reference".

Nic;o)

Hi,

I'm still having no luck I have tried both lines of code as follows and as soon as you run either line it just skips to end function

Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].Form.Fields("Box" & Format(intstart, "00")).BackColor = vbRed
  2.  
  3. Forms![F_EquipBooking]![SF_EquipBooking].Form.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
what is this line supposed to do? im not sure that i understand...

Many thanks Phill
May 6 '08 #6
nico5038
3,080 Expert 2GB
Hi,

I'm still having no luck I have tried both lines of code as follows and as soon as you run either line it just skips to end function

Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].Form.Fields("Box" & Format(intstart, "00")).BackColor = vbRed
  2.  
  3. Forms![F_EquipBooking]![SF_EquipBooking].Form.Fields ("Box" & Format(intstart, "00").BackColor = vbRed)
what is this line supposed to do? im not sure that i understand...

Many thanks Phill
Sorry Phill, I mixed up forms and records, try:
Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].Form.Controls("Box" & Format(intstart, "00")).BackColor = vbRed
  2.  
  3. Forms![F_EquipBooking]![SF_EquipBooking].Form.Controls("Box" & Format(intstart, "00").BackColor = vbRed)
As the fields of a form are called "Controls" :-)

Nic;o)
May 6 '08 #7
phill86
121 100+
Sorry Phill, I mixed up forms and records, try:
Expand|Select|Wrap|Line Numbers
  1. Forms![F_EquipBooking]![SF_EquipBooking].Form.Controls("Box" & Format(intstart, "00")).BackColor = vbRed
  2.  
  3. Forms![F_EquipBooking]![SF_EquipBooking].Form.Controls("Box" & Format(intstart, "00").BackColor = vbRed)
As the fields of a form are called "Controls" :-)

Nic;o)
Hi Nic

Its working :) much appreciated

Phill
May 6 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Dave Robinson | last post by:
I was wondering if anyone could help me with a problem I'm having. I've been using Dreamweaver to create a hotel booking system for a friend of mine, using MySQL (version 4.0.21) and PHP 5. The...
4
by: Grant | last post by:
Hi I have a database which logs the usage of rooms. Some booking are entered well in advance, and some have stays of more than six months. I would like to ensure that rooms which have been...
4
by: WiseOwl | last post by:
Hi folks I teach. At school, four IT rooms are booked using a paper based outline timetable. Completing it is easy but basic and impossible to ensure completion of all fields (name, year...
2
by: Andy | last post by:
Hi folks I teach. At school, four IT rooms are booked using a paper based outline timetable. Completing it is easy but basic and impossible to ensure completion of all fields (name, year...
2
by: Mike Glazer | last post by:
I am trying to construct an Access database to be used for making bookings to share vehicles. The user has to be able to select a starting date and time and an ending date and time. However, when...
20
by: bredal Jensen | last post by:
Hello gurus, I'm building a small booking system and i have come accross quiet a tedious pitfall. "I need to make sure that people do not book for tomorrow when todays time is greater or...
25
by: NDayave | last post by:
How do, I have a access 2000 booking database with Personal Details, Outing Details and the Bookings in three tables: tblBookings -- -Autonumber, -Number, -Number, -Currency, -Yes/No, -Yes/No ...
3
by: Wildster | last post by:
Hi, I have a form in Access 2000 running Windows XP with the following fields: - Booking_ID Date Person_Name Booking_Type 8-9am (y/n checkbox) 9-10am (y/n checkbox)
3
by: Wayne | last post by:
I'm building a bookings database for trucks that among other things captures the TruckName, LoadDate, LoadTime, UnloadDate and UnloadTime. Is there a simple way to prevent double bookings for any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.