Вы можете использовать список обратного вызова для этого.Вот код для одной записи ultimo дат 15 лет назад:
Public Function ListUltimoYears( _
ctl As Control, _
lngId As Long, _
lngRow As Long, _
lngCol As Long, _
intCode As Integer) _
As Variant
' Period for listing dates.
Const cintYears As Integer = 15
' 2014-09-24. Cactus Data ApS, CPH.
Static datFirstDate As Date
Static strFormat As String
Static intRows As Integer
Dim datDate As Date
Dim varValue As Variant
Select Case intCode
Case acLBInitialize
datDate = Date
datFirstDate = DateSerial(Year(datDate), 12, 31)
intRows = 1 + cintYears
strFormat = ctl.Format
varValue = True ' True to initialize.
Case acLBOpen
varValue = Timer ' Autogenerated unique ID.
Case acLBGetRowCount ' Get rows.
varValue = intRows ' Set number of rows.
Case acLBGetColumnCount ' Get columns.
varValue = 1 ' Set number of columns.
Case acLBGetColumnWidth ' Get column width.
varValue = -1 ' Use default width.
Case acLBGetValue ' Get the data for each row.
varValue = DateAdd("yyyy", lngRow, datFirstDate)
Case acLBGetFormat ' Format the data.
varValue = strFormat ' Use format of control.
Case acLBEnd
' Do something when form with listbox closes or
' listbox is requeried.
End Select
' Return Value.
ListUltimoYears = varValue
End Function
Измените его с помощью:
Const cintYears As Integer = 15
, чтобы использовать переменную:
Dim intYears = DateDiff("yyyy", #1/1/1970#, Date)
Toиспользуйте его в форме, установите свойство комбобокса RowSourceType : ListUltimoYears