ClaraBarton
Registered User.
- Local time
- Today, 01:49
- Joined
- Oct 14, 2019
- Messages
- 665
I have a combobox that I want to limit dates in a listbox:
The listbox has a rowsource:
Obviously this thing does not work. To start with the function does not compile. It stops at the first Between. Can you give me a little direction?
Code:
Function DateCalculation(IDate As Integer)
Select Case IDate
Case 48 'All Dates
[CkDate]
Case 49 'This Month
Year([CkDate]) = Year(Date) And Month([CkDate]) = Month(Date)
Case 50 'Last Month
[CkDate] = Date - 30
Case 51 'Last 30 Days
[CkDate] Between(Date - 30) And Date
Case 52 'Last 60 Days
[CkDate] Between(Date - 60) And Date
Case 53 'Last 90 Days
[CkDate] Between(Date - 90) And Date
Case 54 'Last 12 Months
Case 55 'This Quarter
Year([CkDate]) = Year(Date) And DatePart("q", [CkDate]) = DatePart("q", Date)
Case 56 'Last Quarter
IIf(DatePart("q", [CkDate]) = 1, Year([CkDate]) = (Year(Date)-1) And DatePart("q", [CkDate]) = 4, _
Year([CkDate]) = Year(Date) And DatePart("q", [CkDate]) = (DatePart("q", Date)-1))
Case 57 'This Year
Year([CkDate]) = Year(Date)
Case 58 'Last Year
Year([CkDate]) = Year(Date) - 1
End Select
End Function
Code:
Dim ID As Long
Dim IDate As Variant
ID = lngInfoXchg
IDate = DateCalculation cboDate.Value
Me.lstUsage.RowSource = "SELECT TransactionID, fCategoryID, CkDate, Num, Category, Memo, CAmount" & _
" FROM tblNames RIGHT JOIN (tblTransactions LEFT JOIN (tblCategory" & _
" RIGHT JOIN tblCheckCat ON tblCategory.CategoryID = tblCheckCat.fCategoryID)" & _
" ON tblTransactions.TransactionID = tblCheckCat.fTransactionID)" & _
" ON tblNames.NameID = tblTransactions.fNameID" & _
" WHERE NameID = " & ID & _
" AND " & IDate & _
" ORDER BY CkDate DESC"