Hi
As you can see I am new on this. I have a form with monthly data for various year and I want to create a combo box to filter the data by year. I have this event after update on the combo box but it is giving me an error and I do not know why to fix it.
I create a query with every month but the query does not have the date on it. This is why I am using the recordset to pull the field.
Any idea will be greatly appreciate
Private Sub cboYear_AfterUpdate()
Dim DB As Database
Dim RST As Recordset
Set DB = CurrentDb()
Set RST = DB.OpenRecordset("TBMatchAmount")
Dim mthyear As Long
Dim SQL As String
mthyear = RST![MatchMonth]
mthyear = Year(mthyear)
SQL = " SELECT * FROM QRmonthlyReport Where (" & mthyear & ")=" & Me.cboYear & ")"
Me.RecordSource = SQL
Me.Requery
RST.Clone
Set RST = Nothing
Set DB = Nothing
End Sub
As you can see I am new on this. I have a form with monthly data for various year and I want to create a combo box to filter the data by year. I have this event after update on the combo box but it is giving me an error and I do not know why to fix it.
I create a query with every month but the query does not have the date on it. This is why I am using the recordset to pull the field.
Any idea will be greatly appreciate
Private Sub cboYear_AfterUpdate()
Dim DB As Database
Dim RST As Recordset
Set DB = CurrentDb()
Set RST = DB.OpenRecordset("TBMatchAmount")
Dim mthyear As Long
Dim SQL As String
mthyear = RST![MatchMonth]
mthyear = Year(mthyear)
SQL = " SELECT * FROM QRmonthlyReport Where (" & mthyear & ")=" & Me.cboYear & ")"
Me.RecordSource = SQL
Me.Requery
RST.Clone
Set RST = Nothing
Set DB = Nothing
End Sub
Last edited: