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

Auto Updating Calendar OCX on entering form 1

Status
Not open for further replies.

charza

Programmer
Feb 3, 2000
5
US
I'm having a brain-dead day. I have MSCAL ocx on a form, and I need to have it display the current month based on the system calendar.<br>
<br>
What do I need to do to make this happen?<br>
<br>
Your help will earn you my undying gratitude!<br>
<br>

 
Well then how about this<br>
If you want today's date<br>
Me![CalendarCtrl].Value = Format(Now, &quot;mm/dd/yy&quot;)<br>
just make sure its a string<br>
or this for any other date<br>
Me![CalendarCtrl].Value = &quot;4/5/2000&quot;<br>
<br>

 
If this has worked for you, can you give more details? My control name is ctlSelectDate and I've tried this in the OnOpen event of the form, also tried to fill in the Day, Month, and Year properties of the control, also the data source. I don't get errors but my control just sits there at Jan1, 2000.
 
OK here it is believe it or not it will not work in the On_open event <br>
But if you put a commnad button on your form like so and click it the date jumps to today<br>
------------------------------------<br>
Private Sub Command1_Click()<br>
On Error GoTo Err_Command1_Click<br>
Me![Calendar1].Value = Now<br>
Exit_Command1_Click:<br>
Exit Sub<br>
<br>
Err_Command1_Click:<br>
MsgBox Err.Description<br>
Resume Exit_Command1_Click<br>
<br>
End Sub<br>
--------------------<br>
So it that freaky or what<br>
<br>

 
When I do this I get:<br>
<br>
Run time error ''2448''<br>
You can't assign a value to this object<br>
<br>
This is the same message I get if I try to set the date using the Form's OnOpen event with that same format.
 
OK I GOT it<br>
Put the code in the &quot;ON LOAD&quot; event instead of the ON OPEN event and it works.....<br>
<br>
Private Sub Form_Load()<br>
Me![Calendar1].Value = Now<br>
End Sub<br>
<br>
<br>
How about that!!!!
 
Yes! Thanks, I had just figured out that my last reply was a red herring, as I had inadvertantly left a value in the Data Source property. As soon as I removed it I saw your button idea worked. Knew if the code worked but not on OnOpen it must be a timing issue. Open happens before Load. But that's a wierd one!
 
Thanks for the replies! I had already tried that approach but for some reason it displays tomorrow's date.<br>
<br>
Any thoughts?
 
Charza<br>
then your PC clock is 12 hours off<br>
double click on the clock in the lower right hand corner of the sys tray, and see if it says x:xx AM which is not, it should be PM unless of course you are in China.<br>

 
Actually, that's the first thing I checked. The system clock is absolutely correct. (Current date, right time with PM)<br>
<br>
It's a wierd problem...<br>
<br>

 
What is your code to make it see today's date?<br>
Post it here<br>
and what event is it in?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top