Solved

Calender control dates.

Posted on 2004-10-04
2
272 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

732 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