Solved

MSCAL.Calendar.7, setting a default

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

Accepted Solution

by:
Rey Obrero 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now