Results 1 to 3 of 3

Thread: bit of a toughy, i think...

  1. #1

    Thread Starter
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    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

  2. #2
    Addicted Member
    Join Date
    May 1999
    Posts
    161

    Smile

    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...

  3. #3

    Thread Starter
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    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
  •  



Click Here to Expand Forum to Full Width