Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding an ActiveX Calendar 1

Status
Not open for further replies.

Danielle17

Technical User
Apr 17, 2001
102
US
I have a ActiveX Calendar Control on one of my forms. What I would like to do is have it programmed so that when it loads it will check the job tables to see which dates have jobs scheduled for them. Then shade or mark that date on the calendar so that at a glance I can see which days have jobs. I'm far from good at VBA...any help would be greatly appreciated.
 
Hi!

Following code works immaculately.

Private Sub calMyCalendar_AfterUpdate()
Me![MyDate] = Me![calMyCalendar].Value
End Sub

Private Sub Form_Current()
Me![calMyCalendar].Value = Me![MyDate]
End Sub

Bet regards!
Aivars.
 
I've been told repeatedly that shading individual dates on an ActiveXCalendar is impossible. Thanks for some hope. I'm not very good at coding so I have a question.
For the [MyDate] what would I put there...The calendar needs to read between the dates(dates between a job's start and end dates)????
 
Hi!
If you have two date controls, you may have separate CalendarControl for each date (StartDate and EndDate).

Example:
Take Calendar control from Tool box and name it <CalendarForStart>, then take other one and name it <CalendarForEnd>. Then write following codes:

Event <Form>;<On Current>
Private Sub Form_Current()
Me![CalendarForStart].Value = Me![StartDate]
Me![CalendarForEnd].Value = Me![EndDate]
End Sub

Event <CalendarForStart>;<After Update>
Private Sub CalendarForStart_AfterUpdate()
Me![StartDate] = Me![CalendarForStart].Value
End Sub

Event <CalendarForEnd>;<After Update>
Private Sub CalendarForEnd_AfterUpdate()
Me![EndDate] = Me![CalendarForEnd].Value
End Sub

You can make command buttons on this form for set <Today> date of your calendar controls:

Example:
Private Sub cmdTodayStart_Click()
Me![CalendarForStart].Today
End Sub

Private Sub cmdTodayEnd_Click()
Me![CalendarForEnd].Today
End Sub

You also can use calendar controls values for selection data of table (use the command button for this):

Example:
Private Sub cmdSelect_Click()
dim strSQL as string

strSQL=&quot;Select FirstName, SurName, StartDate, EndDate From MyTable Where StartDate>=#&quot; & me![CalendarForStart].Value & &quot;# And EndDate<=#&quot; & me![CalendarForEnd].Value & &quot;#;&quot;

Me.RecordSource = strSQL
End Sub

Best regards!
Aivars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top