Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

Report label in footer section

Please see this screen shot...

report screen shot
"Variance Description Here" is a label.  

Where it reads "Variance Description Here " I want it to read "Record Change" IF there is "Previous Import" AND "New Import" in the detail section.

Where it reads "Variance Description Here " I want it to read "New Employee" IF there is "New Import" But no "Previous Import" in the detail section.

Where it reads "Variance Description Here " I want it to read "Removed Employee" IF there is "Previous Import" But no "New Import" in the detail section.

Make sense?  I expect I need code in the onprint event of the footer section but I don't know how to code it.

--Steve
0
SteveL13
Asked:
SteveL13
  • 2
  • 2
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Steve,

<<Make sense?  I expect I need code in the onprint event of the footer section but I don't know how to code it.>>

You want code in the OnFormat event.

1. Declare variables in the reports module for each of the possible things you want to track (i.e. bolPreviousImport, bolNewImport).

2. In the Groups header OnFormat event, do

   bolPreviousImport = False
   bolNewImport = False

3. In the OnPrint of the detail event:

   If <condition> then bolPreviousImport = True
   If <condition> then bolNewImport = True

4. and last, in the footers OnFormat event:

  Me.txtVarianceMessage = "no variance"

  If bolPreviousImport = True and bolNewImport = True then Me.txtVarianceMessage = "Record Change"
  If bolPreviousImport = False and bolNewImport = True then Me.txtVarianceMessage = "New Employee"
  If bolPreviousImport = True and bolNewImport = False then Me.txtVarianceMessage = "Removed Employee"

  That if logic could be structured a bit better, but it will work and get you started.

Jim.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Note on the group header; it's OK if you don't print anything.  You just need it to execute the code, so just make it visible and set its height to zero.

Jim.
0
 
SteveL13Author Commented:
The only thing I'm not sure of is what to put in the detail onprint section:

Option Compare Database

Dim bolPreviousImport, bolNewImport As String

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

    If <condition> then bolPreviousImport = True
    If <condition> then bolNewImport = True
    
End Sub

Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)

   Me.txtVarianceMessage = "no variance"

   If bolPreviousImport = True And bolNewImport = True Then Me.txtVarianceMessage = "Record Change"
   If bolPreviousImport = False And bolNewImport = True Then Me.txtVarianceMessage = "New Employee"
   If bolPreviousImport = True And bolNewImport = False Then Me.txtVarianceMessage = "Removed Employee"

End Sub

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)

    bolPreviousImport = False
    bolNewImport = False

End Sub

Private Sub Report_Close()

    DoCmd.Restore

End Sub

Open in new window

0
 
SteveL13Author Commented:
I just got it.  Thank you once again.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now