Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Calendar Seminar Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Calendar
Kevin Whitthread 
     
3 years ago
Hi, I have just finished the calendar seminar, I can't seem to get the VBA code to highlight the actual day from the addendum 3 code.
How do I add it to the current VBA code I have to grey out the non-used days.
Thanks
Alex Hedley  @Reply  
           
3 years ago
See Highlight Whole Day for a previous comment about it.

What is currently happening?
Kevin Whitthread OP  @Reply  
     
3 years ago
Nothing is happening, I think I have added it in wrong, please see code below:

Public Sub opencalendar()

Dim x As Integer
Dim s1 As String, s2 As String

  Dim today As Date
  today = Date
    Dim todayDay As Integer
    todayDay = Day(Date)
    Dim todayMonth As Integer
    todayMonth = Month(Date)
   Dim todayYear As Integer
   todayYear = Year(Date)
  

    CalculateStartDate
    DoCmd.OPenFOrm "Monthlycalendarf"
    Forms!MonthlyCalendarF!MonthName = Calendar
    
    
    For x = 1 To 42
    
  
        s1 = "Date" & x
        s2 = "Day" & x
        
        
       If Month(Forms!MonthlyCalendarF!(s1)) <> Month(Calendar) Then
        Forms!MonthlyCalendarF!(s2).BackColor = &HD8D8D8
        Forms!MonthlyCalendarF!(s1).BackColor = &HD8D8D8
        Else
    Forms!MonthlyCalendarF(s2).BackColor = &HFFFFFF
    End If
    Next x
        
        
        
         If (x = todayDay And Month(Forms!MonthlyCalendarF(s1)) = todayMonth And Year(Forms!MonthlyCalendarF(s1)) = todayYear) Then
            Forms!MonthlyCalendarF(s2).BackColor = vbRed
        Else
            Forms!MonthlyCalendarF(s2).BackColor = &HFFFFFF
        End If
        
        
    
        
End Sub
Kevin Robertson  @Reply  
          
3 years ago
Alex I think the is a mistake in the code in that addendum.

If (X = todayDay should be If (Day(Forms!CalendarF(S1)) = todayDay
Kevin Robertson  @Reply  
          
3 years ago
The code to highlight the day needs to be inside the loop.
Here is a snippet from my own database and a screenshot of this month's calendar with today's date highlighted.

    For X = 1 To 42
        S1 = "Date" & X
        S2 = "Day" & X
        If Month(Forms!CalendarF(S1)) <> CalendarMonth Then
            Forms!CalendarF!(S1).ForeColor = RGB(150, 150, 150)
            Forms!CalendarF!(S2).BackColor = RGB(225, 225, 225)
        ElseIf (Day(Forms!CalendarF(S1)) = Day(Date) And _
            Month(Forms!CalendarF(S1)) = Month(Date) And _
                Year(Forms!CalendarF(S1)) = Year(Date)) Then
            Forms!CalendarF(S2).BackColor = RGB(235, 219, 231)
        End If
    Next
Kevin Robertson  @Reply  
          
3 years ago

Kevin Whitthread OP  @Reply  
     
3 years ago
Great! thanks, mate, all ok now.
Alex Hedley  @Reply  
           
3 years ago
Can't remember how old it is, don't think there is even the sample db attached so prob just a copy paste error.
Thanks for fixing it, I'll have to get it ported to the blog engine and then I'll be able to update the page.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Calendar Seminar Lessons.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 6:54:11 AM. PLT: 0s