Help With Some VBA Programming

Dirk2512

Registered User.
Local time
Today, 08:02
Joined
Dec 29, 2006
Messages
15
hi Im updating my database abit, and have run into a problem, i hav a strat time and a duration box, how do i get the DB to stop doule bookings this way
eg: joe Bloggs At 12.30, with a duation of 60minutes
so if anyone tryed to book me for 13.00, a message would come up with an error and next avalible time
eg: sorry booking overlap next avalible time 13.30
here is a copy of the db for any one who wants a look
 

Attachments

I asked if you were going to go in this direction last week. Since you are now, I'd recommend storing the end time rather than the duration. It will be easier query, since you have to calculate the end time to check for conflicts anyway. Also, don't forget you need make sure the proposed booking doesn't overlap in any way, not just its start time. In other words, you don't want someone booking you at 12:00 for an hour, since that would clash with your 12:30.
 
Some more Help

i have redesigned my database, can anyone please prgramme me some code, what i need is the code to automaticlly add 60mins to the start time, and to stop any dounle bookings and any overlaps, if there is a msgbox appers suggesting the avaliable time, please can anyone help, code is not my strong point but i am learning day by day, with peoples help thanks in advance

i have a, call out date, start time, end time fields that order, would upload new db but not enough memory in forum
 
Use the DateAdd function.

DateAdd('h',1,[Date/Time])
 
thanks Keithg, but can you get some code for the checking
 
This should check for conflicts (I'm assuming you don't schedule through midnight):
Code:
  If DCount("*", "tblcallout", "[call out date] = #" & Me.Call_Out_Date & "# " _
                             & "AND [start time] <= #" & Me.End_Time & "# " _
                             & "AND [End time] >= #" & Me.Start_Time & "#") Then
    MsgBox "conflict"
  End If

if you want to get into suggesting nearest/next available times and such, you'll be into some VBA coding for which you'll need a fair amount of code to poke around for openings and a set of rules for the code to follow (first opening after the requested time, nearest opening before or after, etc).

ps. I think I already mentioned what a pain the spaces are. You really should get out of that habit.
 

Users who are viewing this thread

Back
Top Bottom