|
-
Oct 13th, 2000, 10:08 AM
#1
Thread Starter
Hyperactive Member
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
Code:
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
Code:
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
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Oct 13th, 2000, 12:56 PM
#2
Addicted Member
I'm not sure exactly what your final SQL looks like, but if you select the date, it will group by individual date.
You should be able to filter for certain dates without selecting your date and you would then be fine...
-
Oct 13th, 2000, 01:19 PM
#3
Thread Starter
Hyperactive Member
sorry, i should have posted that i figured it out, the SQL statement is turning out to be as long as my arm though....
VB6.0 SP4
Windows 2000
I'm thinking of a number between
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|