Solved

MSCAL.Calendar.7, setting a default

Posted on 2009-07-01
5
395 Views
Last Modified: 2013-11-28
cmdAppointment on frmMain opens frmAppointmentSet which has 2 controls:
(1) oleDate: an MSCAL.Calendar.7
(2) fraType: an Option Group with checkBoxes (3 to choose from: (100) Initial Appointment; (200) Followup Appointment; (300) Cancel

frmAppointmentSet is closed by code placed on the Click event of fraType which stores the variable values in a Public Sub module for later usage.  frmAppointmentSet Load Event runs the sub that I've attached, essentially assigning a default date to Me.oleDate.

If I do not click oleDate, the default assignment succeeds.  If I click a day date on oleDate, the newly assigned date succeeds.  However, selecting only a new year from the MSCAL's built-in dropdown without then clicking on a day-number sets Me.oleDate = 0.  Same failure on the month combo.

What events fire in these built-ins?  I'd add the default mm/dd to year drop-down selections "after update".

Thanks!

GregC
Private Sub Form_Load()
Dim intWeekday
    
    'place and size the popup form
    DoCmd.MoveSize 3.4 * 1440, 5.7 * 1440, 3.6 * 1440, 3.75 * 1440
    
    'default callback date to Monday of next week
    intWeekday = Weekday(Date, vbSunday)    'gets day number of current date
    If intWeekday >= 2 Then                 'finds relative weekday position of current date vs. Monday (e.g. Tue=-1)
        intWeekday = 2 - intWeekday         'sets offset variable used below
    End If
    
    Me.oleDate = Now() + 7 + intWeekday   'offsets current date to this Monday, advances result 7 days (next Mon)
    
End Sub

Open in new window

0
Comment
Question by:Greg-C
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24754646
I can't figure out what your ultimate question is here?

1. Setting Default Values?
2. selecting only a new year from the MSCAL's built-in dropdown without then clicking on a day-number sets Me.oleDate ?
3. Finding out what events fire on a Calendar Control?
Or something else entirely?

1. To set a default date, use the Form Load event.
3. The events that fire on a calendar control can be accessed by going into the visual Basic and selecting the calendar control from the Object list.

JeffCoachman
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 24754755
there is the NewMonth and NewYear event for the Calendar control

test this events


Private Sub oleDate_Click()
MsgBox Me.oleDate.Value
End Sub

Private Sub oleDate_NewMonth()
MsgBox Me.oleDate.Value & " NewMonth Event"

End Sub

Private Sub oleDate_NewYear()
MsgBox Me.oleDate.Value & " NewYear Event"

End Sub
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 total points
ID: 24754943
0
 

Author Comment

by:Greg-C
ID: 24755161
I'm looking over your responses.  I'll get back with an answer directly.
0
 

Author Closing Comment

by:Greg-C
ID: 31598765
Jeff:  I hadn't scrolled through the VB events.  My question was really about Calendar Condrol and your answer was right on.
Capricor1:  Thanks for the code and links.  I'm absorbing all of this.
Split the points and each take 100% of my thanks!

GregC
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question