PJB
Oct 13th, 2000, 10:08 AM
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
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
But when i try to add in something similiar to this
PaymentDate Between #" & DateFrom & "# and #" & DateTo & "#
(selecting the appropriate field in the SELECT portion of my statement and putting it in the GROUP BY portion)
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
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
But when i try to add in something similiar to this
PaymentDate Between #" & DateFrom & "# and #" & DateTo & "#
(selecting the appropriate field in the SELECT portion of my statement and putting it in the GROUP BY portion)
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