The combo and Listbox in Access are different from VB. They do not have Add or Insert methods
You can insert an activex object Microsoft Forms Combo which is the same as VB component.
In Access there is a property Row Source type. This should be set to Value List.
You have to define the Rowsource property of the ListBox
The following code should work
For i = 0 to 6
MyCombo.rowsource = MyCombo.rowsource & DateAdd("d",-1*i,date) & ";"
Next
PS: The column count property should be 1. If you have more than 1 then that many strings separated by ; should be added to rowsource
My solution was very similar I wrote a function;
Public Function Last7Days() As String
Dim i As Integer
Dim DT As Date
Dim SList As String
'DT is current date and the loop deducts a day each time
For i = 0 To 6 'Step -1
DT = Date - i
SList = SList & DT & ";"
Debug.Print SList
Next
Last7Days = SList
End Function
and called the function in the open form procedure:
cboRptDate.RowSource = Last7Days()
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.