Solved

MSCAL.Calendar.7, setting a default

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

775 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