Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
My Date and Time Picker
Jennifer Neighbors 
     
11 months ago
I'm creating a date and time picker form, having watched the seminar on creating appointment calendars. It's mostly working. However, I have two problems: The backcolor of the dates for the prior and following months doesn't render as a different shade of gray than the currently selected month, and when I select the current month, the backcolor of the current date doesn't turn blue. My code:

DetailsPrivate Sub SetDates()

    Dim X As Long
    
    If IsNull(MyDate) Then Exit Sub
    
    For X = 1 To 42
    
        ' Date fields
        Me.Controls("Date" & X) = Format([StartDate] + X - 1, "d")
        
        ' Date colors (in prev/next months) *** doesn't work ***
        If Month(Me.Controls("Date" & X)) <> Month(MyDate) Then
            Me.Controls("Date" & X).BackColor = RGB(236, 236, 236) ' very light gray
        Else
            Me.Controls("Date" & X).BackColor = RGB(187, 182, 174) ' medium gray
        End If
        
        'Events (click a date makes it the currently selected date)
        Me.Controls("Date" & X).OnClick = "=ChangeSelectedDate(" & X & ")"
        
        ' Today's date backcolor  *** doesn't work ***
        If Me.Controls("Date" & X) = Date Then
            Me.Controls("Date" & X).ForeColor = vbBlack
            Me.Controls("Date" & X).BackColor = RGB(132, 161, 198) ' medium blue
        Else
            Me.Controls("Date" & X).ForeColor = vbBlack
            Me.Controls("Date" & X).BackColor = RGB(187, 182, 174) ' medium gray
        End If
        
    Next
    
End Sub


Can anyone spot my mistake?
Jennifer Neighbors OP  @Reply  
     
11 months ago

Kevin Robertson  @Reply  
          
11 months ago
None of the boxes have a date in them.
Instead of:
    If Me.Controls("Date" & X) = Date Then

Try using:
    If Me.Controls("Date" & X) = Day(Date) Then
Jennifer Neighbors OP  @Reply  
     
11 months ago
Hi, Kevin. All of the boxes have a date in them. The date format is "d". If I try your code, nothing changes. (This calendar is for June, although it is labeled as July. I must have made another error, where the label at the top says 'July'. I'll find and correct that. It's a work in progress!)
Jennifer Neighbors OP  @Reply  
     
11 months ago

Kevin Robertson  @Reply  
          
11 months ago
I just tested your code and it works fine.
That is not June's calendar, it is July's. That is why you are not seeing the color change.
Kevin Robertson  @Reply  
          
11 months ago

Jennifer Neighbors OP  @Reply  
     
11 months ago
Thanks for your help, Kevin! I appreciate it.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

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: 5/6/2026 2:23:24 PM. PLT: 1s