Solved

MSCAL.Calendar.7, setting a default

Posted on 2009-07-01
5
385 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
  • 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

679 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