I have a combobox on my form that gets its information from a query to display the Grouped month and year for which data exists in a table.
I have written some vba code to to figure out the last day (e.g. 31, 28, 30) of the month selected for that year.
I then try to filter my form data based on this.
The problem I am having is that I am only receiving an accumulated total for the number of records. e.g. January 2013 will produce the correct filtered data. February will produce the filtered form with the records for January and February. The code is below:
Code:
Private Sub cboFilterFormExpenseMonth_AfterUpdate()
Dim m_month As Integer
Dim m_year As Integer
Dim m_last As Integer
m_month = Mid(Me.cboFilterFormExpenseMonth, 1, 2)
m_year = Mid(Me.cboFilterFormExpenseMonth, 4, 7)
m_date = Me.cboFilterFormExpenseMonth
LastDayofMonth = DateSerial(m_year, m_month + 1, 0)
m_last = Mid(LastDayofMonth, 1, 2)
Me.Filter = "[Payment Date] BETWEEN #01/" & m_date & "# AND #" & m_last & "/" & m_date & "#"
Me.FilterOn = True
End Sub
I feel the code may be horribly inefficient but it was my last resort to try and get this to work.
Any help would be very much appreciated. Thank you.