Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if time is booked in diary

Status
Not open for further replies.

figgis

Programmer
Joined
Nov 3, 2002
Messages
7
Location
GB
Hi
I have written a diary application, but on the diary entry form I want to test if a time is free i.e.

09:30 to 11:30 booked
12:40 to 15:00 booked

If a new entry is made that it is not allowed to enter in any booked time.

This has stumped me for a long time

Jim Johnson
 
figgis

How about something simple like:


If IsNull (Me!txtFIELD) Then Me.AllowEdits = True
Else
Me.AllowEdits = False
End If


'Me.txtFIELD is the diary entry

Tel
 
ah I must have explained my self badly, I have two fields StartTime and FinishTime, as in a diary, I want the user not be able to enter in a time that is alredy boooked,(between these times) obviously if there was only one other booking on a day it would be easy, but there could be an unknown number of bookings. eg

09:30 - 10:30 .
13:00 - 15:00
17:00 - 19:00
all these times are booked

but suppose i want them to insert another entry, how can I program it to check if the time is free (not between 09:30 - 10:30 or not between 13:00 - 15:00 or not between 17:00 - 19:00)

wow I am rambling

Jim
 
Jim

Thanks for the clarification. I always think that the best way to deal with any sort of diary entries is to think of them in terms of fixed slots (say 15 min or half hour slots) eg Ms Outlook Calendar. It's very easy then to see which slots are free and which aren't. Just like booking hotel rooms, or appointments. Can it be arranged so that whoever is booking times in the diary, they have to conform to booking slots, rather than specifiying start and end times? It would certainly solve your problem. Am I over simplifying?

Failing that, and if you're committed to the present way of doing it, then the only way I can see is to have logic that says, for example,

loop through each of the existing booked times
If new_start_time is between existing_start_time and existing_end_time then reject
else accept
end if
next

Sorry if I'm misunderstanding.

Tel
 
Thank you so much for responding, I work in an environment where anyone using word is considered an egg head.

I think you are at the nub of my problem. looping through my recordset of times to check if the slot is free.
I assume it should be a procedure on the after update event of the [StartTime] and the [FinishTime], but I have no idea how to proceed.



 
Well Jim,

I have to say that I'm not a programmer by any means ( more a technical user). If I knew exactly what your table details were I would no doubt work through it in time and get there in the end but I wouldn't like to just offer my code attempts in the forum. I'd take far too long and I'd probably drive you crazy. I think anyone though would need to know a lot more about how your db works. For example, what would you propose to do if someone wanted to book a slot of, say one and a half hours, and there was apparently a time available when required, but only for, say, 1 hour. How would you test for that? I think you're setting yourself a very difficult task when it could be so simple.

Wouldn't you be far better off redoing it so that there are, say, 24 predetermined one hour (or even 48 half hour) slots per day in the diary, (ie fields in the underlying table) which could easily be tested to see if nul? Some one booking one and a half hours would then book three consecutive slots. It would be easy to use, and relatively easy to program, I feel. However there are plenty of gurus here, for sure, who might offer you the clever solution you're looking for. So I might be talking rubbish.

Sorry if I haven't been much help.

Tel
 
Terry
Thank you for your time it has been a help to know it is not an easy task. (will re assign myself as a Technical User) :)

Jim
 
Take a look at the DLookUp function, and consider the BeforeUpdate event procedures of your controls instead of the AfterUpdate ones.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top