What I'm trying to do is get a sum for a field(PaymentAmount) and group them by apartment(aprtmentID) and property(PropertyID) and tenant(CurrentTenant), which i've got working fine
But when i try to add in something similiar to thisCode:Private Sub cmdPrint_Click() Dim DateFrom As String Dim DateTo As String Dim PropertyID As Long Dim Address As String PropertyID = fmrProperty.Data1.Recordset!PropertyID Address = fmrProperty.Data1.Recordset!Address DateFrom = DTPicker1 DateTo = DTPicker2 sqlstring = "Select DISTINCTROW [AptIncome].[aptID], [AptIncome].[PropertyID], [AptIncome].[CurrentTenant], Sum([AptIncome].[PaymentAmount]) AS [Sum Of PaymentAmount]From AptIncome Where PropertyID = " & PropertyID & " GROUP BY [AptIncome].[aptID], [AptIncome].[PropertyID], [AptIncome].[CurrentTenant]" With cmd .ActiveConnection = cn .CommandType = adCmdText .CommandText = sqlstring .Execute End With With rs .CursorLocation = adUseClient .Open cmd End With
(selecting the appropriate field in the SELECT portion of my statement and putting it in the GROUP BY portion)Code:PaymentDate Between #" & DateFrom & "# and #" & DateTo & "#
It starts breaking it down by pay dates again rather then summing them
not sure where to go from there....
oops... sorry about the extremely long sqlstring




Reply With Quote