Generate tomorrows date in combo box

RallyXS

Registered User.
Local time
Today, 03:43
Joined
Aug 18, 2004
Messages
10
Hi All,

Anyone know how to format a combo box to select tomorrows date. I need say the next 7 days dates to be displayed as an option for selection.

Regards,

Scott
 
SELECT dateadd("d",1,now()) as NDate
from some_table
UNION
SELECT dateadd("d",2,now())
from some_table
UNION
SELECT dateadd("d",3,now())
from some_table
;

Basically, this returns the time with it also. But you could create a query like this and base your combobox off of that.
As one way.
 
Change MyCombo to your combo's name:

Code:
Private Sub Form_Open(Cancel As Integer)

    On Error GoTo Err_FormOpen
    
    Dim strList As String
    Dim byt As Byte
    
    Me.MyCombo.RowSourceType = "Value List"
    
    For byt = 1 To 7
        strList = strList & DateAdd("d", byt, Date) & ";"
    Next byt
    
    Me.MyCombo.RowSource = strList
    
Exit_Form_Open:
    strList = vbNullString
    Exit Sub
    
Err_Form_Open:
    Err.Clear
    Resume Exit_Form_Open
    
End Sub
 
Many thanks Fofa, but I went with SJ's solution, as this was how I was taught it at uni. Works great. Was just having a brain fade, as we all do when we've been coding for far too long lol :D

Thanks again
 

Users who are viewing this thread

Back
Top Bottom