MonthView Calendar Control

M

Manuel

I've added a command button to a form (A) which open's another form (B); this
second form (B) contains the Microsoft MonthView Control 6.0 (SP4) calendar
control. I tied a date field from a table (ActualSaleDt) to the Control
Source property of the control; the table is the RecordSorce for form B (and,
indecently, form A as well).

Basically, I added the ActualSaleDt field to form A, and am using form B,
which houses the calendar control, to allow the user to select a date from a
calendar (as opposed to having to manually type the date into the
ActualSaleDt field on the form).

This works fine.

In the AfterUpdate Event of the ActualSaleDt form field I call a function
which archives the data into a table when changes are made. Here's the code.

Public Function ArchActSaleDt(SaleDt As Date, LnNm As Double)

Dim db As DAO.Database
Dim rst As DAO.Recordset

If IsNull(SaleDt) Then Exit Function

Set db = CurrentDb
Set rst = db.OpenRecordset("tbl_SaleDateHist")


rst.AddNew
rst("LoanNum").Value = LnNm
rst("SaleDateHist").Value = SaleDt
rst.Update
rst.Close

End Function

This code works beautifully when the user changes the date directly in the
ActualSaleDt field on the form, but does not work when the user changes the
date using the calendar control; the AfterUpdate does not fire.

Any ideas as to how I can get the VBA code to fire when the user updates the
date using the calendar control?

Thanks,

Manuel
 
T

Tom van Stiphout

On Sat, 1 Mar 2008 18:39:00 -0800, Manuel

Is there a way you can simply call the AfterUpdate procedure yourself?
-Tom.
 
M

Manuel

Problem is that I'd rather not have the user have to call the function
manually by selecting another command button (for example). The code works
so nicely when the user updates the ActualSaleDt field directly; I'd like the
code to execute automatically when the update to the field is done via the
calendar control.
 
T

Tom van Stiphout

On Sat, 1 Mar 2008 20:53:00 -0800, Manuel

I meant what Alex said: call the AfterUpdate procedure from the
appropriate event procedure. This doesn't happen automatically, that's
why I used the term "manually".

-Tom.
 
M

Manuel

I appreciate your responses, but the MonthView Active X calendar control does
not have an After Update Event. The only available Events are: On Updated,
On Enter, On Exit, On Got Focus, and On Lost Focus.

I can call the code from the "On Lost Focus" Event, but that runs the code
each time the form (B) is closed. I only want the code to run when the date
in the field is changed.

Manuel
 
M

Manuel

Ahhh... that worked... not very intuitive. Thanks so much for not giving up
on this, I really appreciate it!

Manuel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top