Solved

Calender control dates.

Posted on 2004-10-04
2
273 Views
Last Modified: 2012-08-14
Hi,

I have a form with a combo box that is populated with a range of dates from a row in excel.

        With .lsDates
            For i = 1 To rngDates.Cells.Count
            .AddItem Format(rngDates.Cells(i).Value, "dd mmmm")
            i = i + 5
            Next i
            .ListIndex = 0
        End With
    End With

This works fine but I was wondering....
Is it possible to use the inbuilt 'calender control 8.0' in excel VBA to do this, but make it so only the dates in my worksheet are available to choose from. Maybe make the other dates greyed out?

Thanks for any help

Chimplet
0
Comment
Question by:Chimplet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
anv earned 500 total points
ID: 12223820
check the following code

Private Sub Calendar1_Click()
For i = 2 To 30 Step 2
    If Calendar1.Day = i Then
        If Calendar1.Month = 5 Or Calendar1.Month = 7 Or Calendar1.Month = 9 Then
            Calendar1.Day = 7
            Calendar1.Month = 8
        End If
    End If
Next

End Sub


it checks if the day is even and month is 5 , 7 or 9 then set the date of day 7 and month 8..

here u can replace the loop with ur loop...comparing te current date with the database values..

like

while not rs1.eof
 
  for i = 0 to lstdates.listcount -1
   if datepart("d",format(rs1!DateVal,"DD/MM/YYYY")) = lstdates.list(i) then
       'do something  since date found in the list controls
   else
    'continue with the loop
   end if
  next
  rs1.movenext
wend
0
 

Author Comment

by:Chimplet
ID: 12251664
Thanks  anv

I will work on your answer later this week.

Chimplet

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 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