Combo Box to List all Future Dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NDayave
    New Member
    • Feb 2007
    • 92

    Combo Box to List all Future Dates

    How Do,

    Is there any way to get a drop down menu to show all dates into the future, without entering them into a table beforehand?

    I really don't want to use the calendar control, but I need to be able to enter any date in the future.

    Cheers,

    NDayave
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    You wouldn't want all future dates listed; the combobox would never finish loading! This example lists the current date and 120 days in the future. You can modify number in this line:

    For D = 1 To 121

    to adjust how many future dates are displayed. Replace cboPickDate with your combobox name.
    Code:
    Private Sub Form_Load()
    
    Me.cboPickDate.RowSourceType = "Value List"
    
    Me.cboPickDate.RowSource = Date
    
    For D = 1 To 121
      Me.cboPickDate.RowSource = Me.cboPickDate.RowSource & ";" & Date + D
    Next D
    
    End Sub
    Linq ;0)>

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Hello, NDayave.

      As an addition to Linq's suggestion.

      In this thread you could find an attachment with a pure SQL method to generate sequential dates list.

      Regards,
      Fish

      Comment

      • NDayave
        New Member
        • Feb 2007
        • 92

        #4
        Cheers, works a treat.

        Just need to format the date to the correct format dd/mm/yyyy and I'm away.

        Comment

        Working...