Results 1 to 4 of 4
  1. #1
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071

    Report Displays differently depending on the view

    I have a report in MS Access 2010. If I run the report using the view Icon the Group Header displays but all other fields are blank. If I run it in Print Preview All fields display as their supposed to with 1 exception. This is a 2 page report and the first record of the second page displays all 0's for the data elements even though the query shows there are numbers there.



    Here's the VBA behind the report. Anybody see anything I'm missing. I stepped through the code and it looks like it's working correctly however when it goes to a new page all of the variables are reset to 0 and I don't understand why.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private lngsRaUTHS As Long
    Private lngCommercialAuths As Long
    Private lngSrmbrship As Long
    Private lngCommmbrship As Long
    Private lngGTSRauths As Long
    Private lngGTcommercialauths As Long
    Private lngGTsrmbrship As Long
    Private lngGTcommmbrship As Long
    Private tpdays As Long
    
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Select Case Me.LOB
            Case Is = "SENIOR"
                If Me.STATUS = 1 Then
                    lngSrmbrship = lngSrmbrship + Me.mbrmonths
                    lngsRaUTHS = lngsRaUTHS + Me.AUTHS
                    lngGTsrmbrship = lngGTsrmbrship + Me.mbrmonths
                    lngGTSRauths = lngGTSRauths + Me.AUTHS
                End If
            Case Is = "COMMERCIAL", Is = "COMM-POS"
                If Me.STATUS = 1 Then
                    lngCommmbrship = lngCommmbrship + Me.mbrmonths
                    lngCommercialAuths = lngCommercialAuths + Me.AUTHS
                    lngGTcommmbrship = lngGTcommmbrship + Me.mbrmonths
                    lngGTcommercialauths = lngGTcommercialauths + Me.AUTHS
                End If
        End Select
    End Sub
    
    
    Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
        Me.txtsRaUTHS = lngsRaUTHS
        Me.txtcommauths = lngCommercialAuths
        Me.txtsrmbrship = lngSrmbrship
        Me.txtcommmbrship = lngCommmbrship
        If lngSrmbrship = 0 Then
            Me.txtsrper1000 = 0
            Me.txtsrauthpermbr = 0
        Else
            Me.txtsrper1000 = (lngsRaUTHS / lngSrmbrship) * (365 / tpdays) * 1000
            Me.txtsrauthpermbr = (lngsRaUTHS / lngSrmbrship) * (365 / tpdays)
    
        End If
        If lngCommmbrship = 0 Then
            Me.txtcommper1000 = 0
            Me.txtcommauthpermbr = 0
        Else
            Me.txtcommper1000 = (lngCommercialAuths / lngCommmbrship) * (365 / tpdays) * 1000
            Me.txtcommauthpermbr = (lngCommercialAuths / lngCommmbrship) * (365 / tpdays)
        End If
        Me.txttotauths = lngsRaUTHS + lngCommercialAuths
        Me.txttotmbrs = lngSrmbrship + lngCommmbrship
        If Me.txttotmbrs = 0 Then
            Me.txttotauthsper1000 = 0
            Me.txttotauthspermbr = 0
        Else
            Me.txttotauthsper1000 = (Me.txttotauths / Me.txttotmbrs) * (365 / tpdays) * 1000
            Me.txttotauthspermbr = (Me.txttotauths / Me.txttotmbrs) * (365 / tpdays)
        End If
        
        
        lngCommmbrship = 0
        lngSrmbrship = 0
        lngsRaUTHS = 0
        lngCommercialAuths = 0
        
    End Sub
    
    Private Sub Report_Load()
        tpdays = DateDiff("d", Forms!form1!txtstart, Forms!form1!txtend) + 1
    End Sub
    
    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
        Me.txtGTSrAuths = lngGTSRauths
        Me.txtGTsrmbrs = lngGTsrmbrship
        Me.txtgtsrauthsper1000 = (lngGTSRauths / lngGTsrmbrship) * (365 / tpdays) * 1000
        Me.txtgtsrauthspermember = (lngGTSRauths / lngGTsrmbrship) * (365 / tpdays)
        Me.txtGTcommauths = lngGTcommercialauths
        Me.txtGTCommmbrs = lngGTcommmbrship
        Me.txtgtcommauthsper1000 = (lngGTcommercialauths / lngGTcommmbrship) * (365 / tpdays) * 1000
        Me.txtgtcommauthspermbr = (lngGTcommercialauths / lngGTcommmbrship) * (365 / tpdays)
        Me.txtgtauths = lngGTSRauths + lngGTcommercialauths
        Me.txtgtmbrs = lngGTsrmbrship + lngGTcommmbrship
        Me.txtgtautsper1000 = (Me.txtgtauths / Me.txtgtmbrs) * (365 / tpdays) * 1000
        Me.txtGTtotauthspermbrs = (Me.txtgtauths / Me.txtgtmbrs) * (365 / tpdays)
        
        
    End Sub

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Never Mind I figure it out I had the re-initialization of those variables in the wrong place.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for sharing your solution. I marked this thread as Solved for you.

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Thanks, I knew there was something I was forgetting.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-11-2012, 07:35 AM
  2. Replies: 2
    Last Post: 12-08-2010, 01:32 PM
  3. Replies: 4
    Last Post: 12-01-2010, 02:42 PM
  4. Report displays no records
    By windwardmi in forum Reports
    Replies: 5
    Last Post: 10-05-2010, 12:10 PM
  5. Open Report or Form depending on condition
    By jheintz57 in forum Forms
    Replies: 5
    Last Post: 03-12-2010, 08:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums