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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with time on a form when working with the next day

Status
Not open for further replies.

load3d

Programmer
Feb 27, 2008
117
US

In reference to the above thread that was answered and resolved.

I'm confused on how to correct this next issue and I won't be able to test it throughly like the rest of the program because I don't work at midnight.

The last thread involved fixing a problem with preventing appointments being created that occur in the past. A problem I can see running into in the future is that if it's 11:30 PM and I try to create an appointment at 12:05 AM then Access will think that this appointment occured in the past.

What is the most effective way to bypass this?

I was thinking..... create an elseif statement that says

let time2 = Time()

Elseif TIME2 > 11:00 PM then (Skip the statement that that checks if the appointment occurs in the past) goto 55

55 runcommand accmdsaverecord
 
Use full DateTime values and test against Now()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
... I don't work at midnight.

But you can set the time on your computer to midnight can't you?

If you are booking appointments (as PHV says) you book them not only at some time but also on some specific day ... for instance today, tomorrow, two weeks from next Wednesday, etc. To do that you must deal with both the date and the time part of your DateTime fields.
 
Very good! Thanks for the input.

This DB is very unique and the appointments are actually only kept for 1 hour so I wasn't considering the date but only the time. The user only inputs the time. The date has to be assumed that it is the same day. Unless of course it's in the middle of the night.



Dim time1 As Date
Dim time2 As Date
Dim time5 As Date


Me.AppointmentTime = Me.Hours & ":" & Me.Mins & " " & Me.Tod


time1 = CDate(Me.AppointmentTime)
time2 = Time()

time1 < time2 Then errmsg402 = MsgBox("You cannot create appointments that occur in the past!", vbOKOnly, "Invalid Appointment Time!")
Me.Hours.SetFocus



I think the best thing to do is bypass this IF statement if the time is passed 11:15 PM.
 
How about compairing the input with now() and if less than now its in the past so increase the date by one.

As everyone else has said , you should be using dates and times.

you can set the default date to today using date()

Ian Mayor (UK)
Program Error
If people say I have bad breath, then why do they continue to ask me questions and expect me to answer them?
 
How are ya Mbarbine . . .

Since your locked in by an hour before the day ends, how about the following:
Code:
[blue]   Dim appTime As Date
   
   appTime = #12:05:00 AM#
   
   If Not (appTime >= #12:00:00 AM# And appTime <= #12:59:59 AM#) Then
      [green]'your code here[/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 






"This DB is very unique and the appointments are actually only kept for 1 hour so I wasn't considering the date ..."

How myopic and short sighted! Here you are, capturing data and then throwing it away the next day. Is that REALLY what you and your management want to do?

Is there absolutely no value at all to this data historically?

Will a question never be asked regarding what appointments occurred on June 6, 2008, or how appointments in the first quarter of 2007 compare to the appointments in the first quarter of 2008?

Maybe I'm all wet???

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I value your critique. This is my fault, but the appoinments are kept in the database table for longer than an hour but they are only displayed for 1 hour from the time they are created. That is what i meant by them only being "kept" for 1 hour. At no point in time will an appointment be created for an hour in advance. Appointments are created in 5 minute increments and only take 5 minutes to complete. The appointment data is stored for 90 days and I do have a report that shows completed appointments and a report that shows reports that were cancelled automatically (after 1 hour).
 




"The appointment data is stored for 90 days..."

If you do not store the DATE, how do you know when 90 days has transpired?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 




Ahhhhhhh.

So you could compare the AppointmentTime to the TimeStamp Time.

If the AppointmentTime is less than the TimeStamp Time, the Date associated with the AppointmentTime is the TimeStamp Date + 1. Otherwise, the Date associated with the AppointmentTime is TimeStamp Date. Is that true?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yes. That is correct. I was thinking that if the timestamp time > #11:00 PM# then skip the IF statementthat says you cannot create appointments that occur in the past and save the record anyway.
 
. . . and my post?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Yes you're correct. I don't understand why I would do date + 1 though. Once the person has arrived for their appointment their badge is scanned and the appointment is then complete. When you entire the appointment you specify the badge#. So....with that said.... and then the arrival time stamp is recorded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top