Calendar question

jacks

Registered User.
Local time
Today, 23:46
Joined
Jun 3, 2007
Messages
28
probably a simple question.. but it's giving me headache.

I'v a form with two controls.

date
Calendar2 (an activeX control : MSCAL.Calendar.7)

The control source of the calendar set to date
the date control source set to date too..

If I click on a day in the Calendar, I want to see the change in date.
And I can't get the stupid thing to do so.

For the Calendar control I have the event :
OnUpdate

There I placed the code :
date = Calendar.Value
Me.Refresh

but it's not working. no matter what I click.. the date doesn't show updated until I click outside of the calendar control (place the focus on another control)

How can I change that ? I think it has to do with events.. but I can't figure it out.
 
date is a reserved word in access. Change the name of the control to something else and try again
 
okay.. i'm dutch. Let me explain it a bit better.

The form is based on a table match.
The table match has a column named "datum" with the format date.

On the form I have a text box labeled datum and named "datum".
The control source for the text box is "datum" which is the column in the table match.

Then there is that Calendar control.
it's named "Calendar2" and I have as Control Source "datum".

In the OnUpdate event I have:
datum = Calendar2.Value
Me.refresh (in the hope that the entire form refreshes and datum shows the updated value of the calendar)

when I click on the calendar, nothing visible happens. And I thougth, the OnUpdate event fires, the datum field gets the Calendar value and the form is refreshed, so I should see the new value that I just clicked. So, to my surprise it didn't work that way.

After I click on a date in the calendar control the date doesn't change. If I then click on another text field, then it does change.

apparently the my.Refresh doesn't work or so.. I have no idea why I don't see the change of date immediately in the text box.
 
The control source for the text box is "datum" which is the column in the table match.

Then there is that Calendar control.
it's named "Calendar2" and I have as Control Source "datum".

So you are saying that both controls are bound to the same field? Not what you want to do. The calendar control shouldn't have a controlsource and the AfterUpdate event of the calendar should set:

Me.YourTextBoxName = Me.Calendar2.Value

But, make sure your Text box name is NOT named datum, as that is your field, name it something like txtDatum.
 
So you are saying that both controls are bound to the same field? Not what you want to do. The calendar control shouldn't have a controlsource and the AfterUpdate event of the calendar should set:

Me.YourTextBoxName = Me.Calendar2.Value

But, make sure your Text box name is NOT named datum, as that is your field, name it something like txtDatum.

there's no AfterUpdate event.

There'r five events :
1. On Updated
2. On Enter
3. On Exit
4. On Got Focus
5. On Lost Focus

I removed the ControlSource from the Calender control
Renamed the datum Text box to txtdatum (and the label to datum2, just to be sure)

but still it doesn't work.

I'v put a break point on the assignment : Me.txtdatum = Me.Calendar2.Value but the program is not stopping there..

I'v played with the exit and enter events.. putting the assignment there.. but I must be doing something else wrong I guess... or the control sucks ? is that possible ?
 
Last edited:
Then it would be the OnUpdated and I know you said you tried that, but given you had the control sources slightly askew, you might try it again with my suggestions.
 
Then it would be the OnUpdated and I know you said you tried that, but given you had the control sources slightly askew, you might try it again with my suggestions.

it still doesn't work.. the code that I expected to be executed on the firing of the event :

Private Sub Calendar2_Updated(Code As Integer)
Me.txtdatum = Calendar2.Value
Me.Refresh
End Sub
 
When I get home I'll try to check the calendar control myself. I don't seem to have it here at work.
 
When I get home I'll try to check the calendar control myself. I don't seem to have it here at work.

it's strange because I'v everything the way you suggested me.
And now the date doesn't get into the txtdatum at all anymore.

the On Updated doesn't work. Otherwise it would have stopped on the breakpoint. That did work on the On Focus event when I tried that.

I use Access 2003, and I inserted Calender Control 11.0. It's simply chosen from a list when you pick controls and select more controls.
 
Last edited:
it's strange because I'v everything the way you suggested me.
And now the date doesn't get into the txtdatum at all anymore.

the On Updated doesn't work. Otherwise it would have stopped on the breakpoint. That did work on the On Focus event when I tried that.

Actually, I would suggest using a NON Active X control solution that I use or one of the other ones around here.

This is the one I use (it does a little popup that you can assign to the text box).
http://www.access-programmers.co.uk/forums/showthread.php?t=103387
 
As an addendum to the advice offered about not naming controls/variables the same name as Reserved Words in Access, the danger in doing so with Date and Time is that as statement like Date = "1/1/08" will actually set your computer's system date to next New Year's Day! :eek:
 
Actually, I would suggest using a NON Active X control solution that I use or one of the other ones around here.

This is the one I use (it does a little popup that you can assign to the text box).
http://www.access-programmers.co.uk/forums/showthread.php?t=103387

ah.. that one looks good. I'll try to use it on my Text Box.. OK. That works.. unfortunately it's not doing what I want. I want to enter a few records with a date that I select at the beginning of entering records. I don't want to have to select a date every time again..

I'm still disappointed that the standard control that came with the MS Access program versioned 11.0 doesn't work.
How is that possible.. amaaaazing.
 
Last edited:
I'v found it !!!

It's pretty simple actually.. but one has to know how to find it.

The properties of the Calendar control show only 5 events, while there are 14.
Go to the code editor, select the Calendar object from the dropdown box at the top, right next to it is the method drop down. Select that drop down box... and there you are !! 14 methods available.. including the very very very simple : OnClick(). Just what I needed and what works.

My god.. I hope Access isn't gone present me more surprises like this.
 
Access is full of such surprises - that's what makes it so much fun.

Chris B
 

Users who are viewing this thread

Back
Top Bottom