Results 1 to 2 of 2
  1. #1
    princeofdumph is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    4

    vba code required for report

    hi,
    i have created a report which shows a number of columns for each employee. however, not every column is relevant to any given employee. For example, lets say 'M' is an employee and columns 8 and 9 are irrelevant to him. but whenever i see Mr. M's report page, it shows these two columns in page header and their "zero" values in details section and so on for other employees.


    I want a VBA code which hides such columns totally following some kind of condition for every employee. I think i'll have to put it in the On Print event line. but dont know how to write such a code and where exactly to put it to work. Can anyone help?

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    There's probably some way to do it by setting the Column Header's (I'm assuming it's a Label?) .Visible property.

    However, the easiest say, IMO is to just have a check in each Column that says If the column doesn't apply, print "N/A"

    If you're hellbent on making the Label invisible, you'd probably put the code in the Report's OnOpen event. Maybe something like this (I haven't actually tried it, so I don't know if this will really work or not):
    Code:
    If Len([Column8] & vbNullString) = 0 Then
      Me!Label8.Visible = False
    Else
      Me!Label8.Visible = True
    End If
    Assuming [Column8] is the name of the Table field containing the null data and that Label8 is the name of the Column Header you want to hide.

    Generally speaking, I try to stay away from coding in Reports though so I don't know the exact syntax.

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

Similar Threads

  1. Problem in report and used code...
    By manos39 in forum Reports
    Replies: 12
    Last Post: 11-23-2011, 05:24 PM
  2. Help Required on Report List
    By cap.zadi in forum Reports
    Replies: 9
    Last Post: 09-23-2011, 05:10 PM
  3. SQL Code to Make Query / Report
    By agent- in forum Programming
    Replies: 10
    Last Post: 06-17-2011, 04:14 PM
  4. how to change report code page
    By broken_ice in forum Reports
    Replies: 1
    Last Post: 06-27-2010, 02:23 AM
  5. code to print just first page of a report
    By tonyrice in forum Reports
    Replies: 1
    Last Post: 02-14-2007, 03:07 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