Control giving unexpected output

grenee

Registered User.
Local time
Today, 02:13
Joined
Mar 5, 2012
Messages
212
My unbounded control has row source type as Table/Query and the row source as a table field "StaffStartTime" with datatype Date/Time medium time.

This field contain the following values "8:00 AM" and "11:00 AM".

pressing a button of the form causes the value in the control to be displayed as 12:00 AM, irrespective of which value is selected in the control

This means it is not recognizing the entries.

I would be grateful to have this problem explained.
 
What's the code being executed when the button is clicked?

If the format for your combo is medium date, and the combo's value is set to zero, it will display 12:00am
 
My combo is "SheduleArrival" and the button is "AutoSave".

The format of the combo is medium date but the combo's value is set to either 8:15 AM or 11:00 AM; never to zero.

When "AutoSave" is pressed the code executed is: me.ScheduleArrival
 
Actually I just discovered that my problem is really a different one. Here's the problem:
I have the combo value wrapped with DateValue function like so: Datevalue(Schedule Arrival).

Ultimately, what I am trying to do is add 8:00 AM to today's date so I tried:

if now() >DateAdd("n", 15, DateValue(Me.Schedule_Arrival) + DateValue(Date)) then
msgbox "I am Late"
else: " I am Early"
End if

the result is always "I am late". So this led me to test the combo separately ie. : DateValue(Me.Schedule_Arrival)
and this is returning : 12:00 Am even though the value in the combo box is : 8:00Am
 
Try typing
? DateAdd("n", 15, DateValue(Me.Schedule_Arrival) + DateValue(Date))
in the immediate window and you will always get 12.15 am today - doesn't matter what time is selected in your combo. (That's because datevalue() expects a string, not a time from your combo).

What you need is
dateadd("n",15, Date() + Me.Schedule_Arrival)
 

Users who are viewing this thread

Back
Top Bottom