Hi all!
I have an accounting application where I want to produce a a query that feeds a report where I can show total receipts by month comparing year and month this year versus last year. When I run the query, I want to break the date down to two different fields Year "2005" and "Jan". I will then sort these fields on my report by year and by month. To do this I need a function that will call from my query that will do this. So far, I've used the following within a form to do this but I can't seem to get it to work within the query. Please be kind as I'm not that strong in VBA!
Private Function FinalSave()
On Error GoTo FinalSave_Err
'Assigns the accounting month at the time cash is entered
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT TOP 1 tblCalandar.AMonth FROM tblCalandar WHERE (((tblCalandar.AEnd) >= Date())) ORDER BY tblCalandar.AEnd;"
rs.Open strSQL, CurrentProject.Connection, adOpenStatic
' Debug.Print strSQL
' Debug.Print rs.RecordCount
Me!txtDetailPeriod = Left(rs!AMonth, 3)
Me!txtPeriodDetail = rs!AMonth
Me!txtPeriodHeader = rs!AMonth
rs.Close
Set rs = Nothing
conn.Close
End Function
Thanks again for any help!!
Regards!
Itch
I have an accounting application where I want to produce a a query that feeds a report where I can show total receipts by month comparing year and month this year versus last year. When I run the query, I want to break the date down to two different fields Year "2005" and "Jan". I will then sort these fields on my report by year and by month. To do this I need a function that will call from my query that will do this. So far, I've used the following within a form to do this but I can't seem to get it to work within the query. Please be kind as I'm not that strong in VBA!
Private Function FinalSave()
On Error GoTo FinalSave_Err
'Assigns the accounting month at the time cash is entered
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT TOP 1 tblCalandar.AMonth FROM tblCalandar WHERE (((tblCalandar.AEnd) >= Date())) ORDER BY tblCalandar.AEnd;"
rs.Open strSQL, CurrentProject.Connection, adOpenStatic
' Debug.Print strSQL
' Debug.Print rs.RecordCount
Me!txtDetailPeriod = Left(rs!AMonth, 3)
Me!txtPeriodDetail = rs!AMonth
Me!txtPeriodHeader = rs!AMonth
rs.Close
Set rs = Nothing
conn.Close
End Function
Thanks again for any help!!
Regards!
Itch