date change based on time.

gocoder

Registered User.
Local time
Today, 01:21
Joined
Sep 16, 2014
Messages
10
I have a form and I want the dates to be displayed based on predefined time.
In this case, I want my form to show present date from present day's 7:00 AM to next day 7:00 AM.
 
I have a form and I want the dates to be displayed based on predefined time.
In this case, I want my form to show present date from present day's 7:00 AM to next day 7:00 AM.

Do you mean you want to filter the dates displayed in a datasheet form based on what time it is?
 
Partly..yes. This form where date appears is not datasheet form.
Users don't enter date. Date has to be automatic based on time.7:00 am(d) to 7:00 am(d+1)
Users enter other data like name, ID, machine etc in this form and save it.
The above data is stored in a table. Using other forms, I would filter the above entered data from this table.
 
I'm still not clear...

Are the following correct?
The form is for entering one record at a time.
There is more than one date to be added automatically is a bound Textbox.


You want the code to check the current time and if it is between 7am today and 7am tomorrow, you want todays date. Outside of those times you want the code to enter tomorrow's date?
 
yes,The form is for entering one record at a time.It is a bound textbox to a field SCRAP_DATE
I want the code to check the current time between 7 am today to 7 am tomorrow and display today's date. After tomorrow's 7 am, it should display tomorrow's date.
 
yes,The form is for entering one record at a time.It is a bound textbox to a field SCRAP_DATE
I want the code to check the current time between 7 am today to 7 am tomorrow and display today's date. After tomorrow's 7 am, it should display tomorrow's date.

Is the "Time" stored in a textbox on your form?

If so what is the name of the textbox?
 
The date will change at 1200 midnight. If you want tomorrow's date to start at 0700am then use the time - 7 hours as your display.
 
The following code solves my date issue based on time, 7:00 AM to 06:59(Day+1).

Option Compare Database

Function Calcul_Date_mi()


Dim date_m As Variant
Dim nn As Variant

nn = Time

If nn >= TimeSerial(0, 0, 0) And nn < TimeSerial(7, 0, 0) Then
date_m = Date - 1
Else
date_m = Date
End If

Calcul_Date_mi = date_m

End Function
 

Users who are viewing this thread

Back
Top Bottom