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

Tip: Using Calender control with Date & Now

Status
Not open for further replies.

elizabeth

IS-IT--Management
Sep 16, 1999
1,196
US
A question came up a while back about the Calendar Control. For some reason you can't set the value through the containing form's OnOpen method, although DougP found you can use the OnLoad event. A second question arose that I didn't see answered; sometimes the date was exacly one day later than the system date.<br>
<br>
I've found that the Now function gives the correct date (in the calendar control) only in the morning. Once the system date moves to the PM, the calendar control shows the next day's date. However, the Date function works correctly AM or PM.<br>
<br>
Bug or Feature? You decide! :)<br>
<br>
If anyone has noticed this difference showing up anywhere else or another way to load the calendar value, please post it. Thanks.
 
Interesting.<br>
I have never had &quot;NOW&quot; give anything but the correct date.<br>
I would know cause 25 users who live with 34 Access data bases all day long would have said something in 2 years.<br>
<br>
We all have NT workstation's if that makes a difference.<br>
<br>
Is it possible that the machines are not using the &quot;Eastern Standard Date&quot; in Control Panel &quot;Date and Time&quot;<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
I am also on NT using EST, but I wouldn't expect Now & Date to behave differently based on the same system clock, or for the system clock to work differently in a given time zone. It seems to be a Calendar Control thing. <br>
<br>
I'm using the Calender Control version 8.0 that ships with Access 2000. Maybe this is a problem only with the new version, if no one has seen this AM/PM behavior with any other control.
 
Last and final right way to use the calendar control<br>
<br>
in order for it to have the correct date in the afternoon use this:<br>
ActiveXCtl12.Value = Format(Now, &quot;mm/dd/yy&quot;)<br>
<br>
NOT this<br>
ActiveXCtl12.Value = Now<br>
<br>
If you use this second one it will show tomarrow's date<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Thanks, I get it... a rounding error!
 
OK, I get it now.

In Access 2000, With the 9.0 Calendar Control, you have to set the Value in the On_Load Event.

As DougP stated,

ActiveXCtl4.Value = Format(Now,&quot;mm/dd/yy&quot;)

sets the calendar control to today's date.

Isn't Tek-Tips Forum great? I'd never have figured this out on my own. Thanks All.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top