Results 1 to 4 of 4
  1. #1
    degras is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    72

    Columns not being hidden

    I am trying to hide some columns in a subreport based on the value of a field in the main report. The columns are not being hidden. The code seems to be ignored. Any ideas as to why the code is not executing? Here is the code (under the detail - OnFormat event) :

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


    Me!ItemsSubreport.Form!ItemDate.ColumnHidden = True
    Me!ItemsSubreport.Form!Qty.ColumnHidden = True
    Me!ItemsSubreport.Form!PercOfTotal.ColumnHidden = True
    Me!ItemsSubreport.Form!Employee.ColumnHidden = True
    Me!ItemsSubform.Form!UnitPrice.ColumnHidden = True

    If Me.Category = "Service" Then
    Me!ItemsSubreport.Form!ItemDate.ColumnHidden = False
    Me!ItemsSubreport.Form!Qty.ColumnHidden = False
    Me!ItemsSubreport.Form!UnitPrice.ColumnHidden = False
    End If
    If Me.Category = "Salary" Then
    Me!ItemsSubreport.Form!ItemDate.ColumnHidden = False
    Me!ItemsSubreport.Form!PercOfTotal.ColumnHidden = False
    Me!ItemsSubreport.Form!Employee.ColumnHidden = False
    End If
    If Me.Category = "Sales" Then
    Me!ItemsSubreport.Form!Qty.ColumnHidden = False
    Me!ItemsSubreport.Form!UnitPrice.ColumnHidden = False
    End If
    End Sub

    ... (Update) I found out that the code does not fire untill the report prints out. Now I get an error on the first line of code:

    Me!ItemsSubreport.Form!ItemDate.ColumnHidden = True

    ... it seems this is not the right syntax for accessing the fields on the subreport.
    Last edited by degras; 01-20-2011 at 10:39 AM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Try

    Me!ItemsSubreport.Report!ItemDate.ColumnHidden = True

    The detail format event does not fire in the new Report view, only in Preview and printing out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    degras is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    72
    Quote Originally Posted by pbaldy View Post
    Try

    Me!ItemsSubreport.Report!ItemDate.ColumnHidden = True
    Oh dear, I tried this and I still get an error: 2455.

    I tried the following, I don't get an error but the column heading is still visible, although the field does seem to disappear:

    Me!ItemsSubreport.Report!ItemDate.Visible = False

    ... what I wanted to do was to hide the column.
    Last edited by degras; 01-25-2011 at 08:43 AM.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    ColumnHidden is for datasheet view, Visible for others. What view is the subreport in?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 0
    Last Post: 01-18-2011, 07:09 AM
  2. Help - activate hidden control
    By Belxaviar1973 in forum Forms
    Replies: 2
    Last Post: 08-31-2010, 09:20 AM
  3. Hidden Attributes
    By NMJones in forum Access
    Replies: 1
    Last Post: 02-09-2010, 10:57 AM
  4. subform controls hidden
    By bkelly in forum Forms
    Replies: 0
    Last Post: 09-26-2009, 10:12 AM
  5. Unhide Hidden Query
    By Valeda in forum Queries
    Replies: 2
    Last Post: 05-12-2006, 05:58 AM

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