Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29

    Hide fields that don't have value in a Report

    Hi,

    I need some help width a problem. I need to hide some fields and labels that don't have value on it in the report. I have tried this code:

    Option Compare Database



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


    End Sub
    Private Sub Detalhe_Print(Cancel As Integer, PrintCount As Integer)
    If IsNull(Me.apoiofinanceiroaprovado) Or Me.apoiofinanceiroaprovado = "" Then
    Me.Rótulo45_Rótulo.Visible = False
    Else
    Exit Sub
    End If


    End Sub
    But it don't work. The field and the label without values are still appearing on the report.
    Could someone help me?
    Regards

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You need to place your code in the Detail's Format event. You have it in the Print and this is too late. The report has already rendered by then.

  3. #3
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Hi,

    I tried this:

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


    End Sub


    Private Sub Detalhe_Format(Cancel As Integer, FormatCount As Integer)
    If IsNull(Me.apoiofinanceiroaprovado) Or Me.apoiofinanceiroaprovado = "" Then
    Me.Rótulo45_Rótulo.Visible = False
    Else
    Exit Sub
    End If


    End Sub
    And its not working to. Can You explain me why?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I am going to guess Detalhe translates to Detail.

    I would try something like this. I just looked at some of my code and I have examples of using the Visible property in the Detail Format of Reports.
    .
    Else
    Me.Rótulo45_Rótulo.Visible = True
    End If


    Here is one of my examples.
    Code:
    If Me.DispFeet.Value = -1 Then
    Dim sglFeet As Single
        sglFeet = Me.PieceSize.Value
        Me.txtFeet.Value = sglFeet / 12 'adjust the unit of measurement to feet from inches
        Me.txtFeet.Visible = True
        Me.PieceSize.Visible = False
    Else
        Me.txtFeet.Visible = False
        Me.PieceSize.Visible = True
    End If

  5. #5
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Thanks for Your Help!
    I wrote based on Your code this code:

    Private Sub Detalhe_Format()


    End Sub


    If Me.apoiofinanceiroaprovado.Value = 0 Then
    Dim apoiofinanceiroaprovado As Single
    Me.apoiofinanceiroaprovado.Visible = True
    Me.apoiofinanaceiro_Rótulo.Visible = False
    Else
    Me.apoiofinanceiroaprovado.Visible = False
    End If

    Yes Detalhe is Detail and is were the field is. The name of the field is apoiofinanceiroaprovado. And apoiofinanceiro_Rótulo is the title of the Field.
    Anyway, Your code don't work to.
    I have seen the first code I wrote here work if the area is the Header_Print. But with Detail_Print don't work and Detail_Format don't work to.
    I don't know if is the version of the access I have. It is possible?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I suggest you use code tags when showing code.

    Type your vba (or copy/paste) then select/highlight, then click the # sign in the row above this posting area.

    Code:
    Private Sub Detalhe_Format()
    
    
    End Sub '???????????????????????????????????????????
    
    
    If Me.apoiofinanceiroaprovado.Value = 0 Then
    Dim apoiofinanceiroaprovado As Single
        Me.apoiofinanceiroaprovado.Visible = True
        Me.apoiofinanaceiro_Rótulo.Visible = False
    Else
        Me.apoiofinanceiroaprovado.Visible = False
    End If
    
    'End Sub should be here !!!!!!!!!!!!!!!
    But in your code, you have the End Sub in the wrong place.

  7. #7
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Don't work Your code!!! I copy and paste your code but nothing works.
    It send a message: "Procedure declaration does not match description of event or procedure having the same name"
    And says to that is expected a name of the macro?????
    If I take off the name "Sub" he don't send message of error, but don't hide the field to.

    I don't understand nothing of VBA code.
    Can I send You the Zip file of the Data Base? Maybe You can do it to work.
    Thanks for all your help!

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I think the issue here is the detail section works a lot like a continuous form(NOT True). Whatever the properties are of the first control, the properties of the subsequent controls will be the same.

    Edit: The above statement is not correct. I was mistaken and tested the following code. It works just fine, hiding abbreviations for states like California while showing abbreviations for states like Alabama.

    Code:
    If InStr(Me.States.Value, "C") Then
        Me.Abbreviations.Visible = False
    Else
        Me.Abbreviations.Visible = True
    End If
    Last edited by ItsMe; 05-07-2015 at 06:06 PM.

  9. #9
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    I wrote the following code:
    Code:
    If InStr(Me.apoiofinanceiroaprovado.Value, "") Then    Me.apoiofinanceiroaprovado.Visible = False
    Else
        Me.apoiofinanceiroaprovado.Visible = True
    End If
    And it is not working!!! I don't know what to do more!!!! This code give me a message: Procedure declaration does not match description of event or procedure having the same name.
    What did I do wrong?

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    This does not help
    And it is not working!
    What are you trying to do in plain English? Show us a sample of input and expected output.
    Do you get an error message? If so, what is the message?

    If English is not your mother tongue, then write a description in your native language and use Google translate to get English output.

    You do not need .value. It seems you may have 2 things with the same name??? Have you tried google to see if others have had the error?
    see https://msdn.microsoft.com/en-us/lib.../gg264805.aspx

    For examples and syntax of Access functions

  11. #11
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Orange
    I have wrote the code that the user ItsMe wrote on this topic forum. In her code there was ".value". I try all the codes people send me here. But none of them work.
    And I don't understand nothing of VBA code.
    I send here an image of what I want.Click image for larger version. 

Name:	report.png 
Views:	12 
Size:	170.5 KB 
ID:	20614

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  13. #13
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Thanks for Your help. I am going to look for those tutorials.

  14. #14
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You have

    Code:
    If InStr(Me.apoiofinanceiroaprovado.Value, "") Then    Me.apoiofinanceiroaprovado.Visible = False
    Else
        Me.apoiofinanceiroaprovado.Visible = True
    End If
    I would use this to check for null. Make sure you start a new line after "Then" and after "False" and after "Else" and after "True"
    Code:
    If isnull(Me.apoiofinanceiroaprovado.Value) Then
        Me.apoiofinanceiroaprovado.Visible = False
    Else
        Me.apoiofinanceiroaprovado.Visible = True
    End If

  15. #15
    Vandacardoso is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    29
    Hi,
    This code don't work ;-( .
    I don't know what to do anymore!!!!
    But thanks for your help ItsMe!

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sum fields to hide zero values
    By Sparkwoodand21 in forum Queries
    Replies: 9
    Last Post: 04-07-2015, 05:23 PM
  2. Replies: 10
    Last Post: 03-11-2015, 03:25 AM
  3. Replies: 4
    Last Post: 02-04-2013, 02:15 PM
  4. Cannot hide fields in a datasheet
    By desgordon in forum Forms
    Replies: 2
    Last Post: 08-19-2009, 03:24 PM
  5. how to hide the fields in subform
    By tinytree in forum Forms
    Replies: 3
    Last Post: 05-01-2009, 07:56 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