Results 1 to 6 of 6
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Visibility of field on report.

    In my application on the form Assets, when the "Asset Type" is a vehicle, a field "VehicleModel" on the sub form becomes visible.
    The field "VehicleModelA" is on the Sub form linked to query q01AssetSub. The VBA code is on the Main Form under Current event.
    On the form I use the following VBA code and it works well on the form.
    I need to learn to do the same on a report.

    If Me.cboAsstyp_IDa = 762 Then
    Forms("f01AssetsMain").Controls("f01AssetsSub").Fo rm.Controls("Vehmod_IDa").ColumnHidden = False


    Else
    Forms("f01AssetsMain").Controls("f01AssetsSub").Fo rm.Controls("Vehmod_IDa").ColumnHidden = True
    End If

    In most cases the reports display similar to the forms.
    I use changing visibility of fields on many places in the app.
    I have tried various ways, for the field "VehicleModel" is on the Sub Report.
    Main report name: r01AssetsMainInfo
    Sub Report name: r01AssetsSub
    Field Name on Sub Report: txtVehicleModelA

    I tried the code below on the main report. No success yet.
    If Me.AssetTypeA = "Vehicles" Then
    Reports("r01AssetsMainInfo").Controls("r01AssetsSu b").Report.Controls("txtVehicleModelA").ColumnHidd en = False
    Else
    Reports("r01AssetsMainInfo").Controls("r01AssetsSu b").Report.Controls("txtVehicleModelA").ColumnHidd en = True
    End If

    I also tried placing VBA on the Sub report.
    If Me!txtAsstyp_IDa = 762 Then
    Me.txtVehicleModelA.Visible = True
    End If

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    columnhidden is a property of a datasheet not a single or continuous form or report

    to affect the visibility of a control on a report you use code in the format event of the appropriate section

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    What event did you place the code in?
    Try in in the OnFormat event.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    [QUOTE=CJ_London;507636]columnhidden is a property of a datasheet not a single or continuous form or report

    Thank you.
    Maybe I misunderstand. As I stated the columnhidden code works on the form.
    I will try what you suggest and reply.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    As I stated the columnhidden code works on the form.
    it will if the form is a datasheet form

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thank you. I did what you suggested and it works.

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

Similar Threads

  1. Field visibility false, on a sub report.
    By Perfac in forum Reports
    Replies: 5
    Last Post: 12-08-2022, 07:51 AM
  2. Replies: 8
    Last Post: 12-13-2016, 02:11 PM
  3. Macro using IF to set visibility in report
    By kyle87 in forum Macros
    Replies: 8
    Last Post: 07-23-2013, 01:24 PM
  4. Field visibility in a report
    By PhilTFC in forum Forms
    Replies: 8
    Last Post: 10-29-2012, 12:10 PM
  5. Field Visibility
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 06-27-2012, 03:52 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