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, "mm/dd/yy"<br>
just make sure its a string<br>
or this for any other date<br>
Me![CalendarCtrl].Value = "4/5/2000"<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 "ON LOAD" 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!
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>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.