none
Hide a field based on a value in another field RRS feed

  • Question

  • Good morning,

    I have 2 fields on a report, one is named "Quantité" and the other one is named "QuantitéOK", I was able in a query to obtain a result into the field QuantitéOK that is correct.

    The query named "CouponCuisine Requête pour impression" has a field named "Nom du produit" if that field begins by the letters "EXTR*" then I want the field QuantitéOK to show 0 (zero) for anything else show the quantité value.

    That query resolve 50% of my problem.

    Now in the report based on that query, I want the field "Quantité" not to be visible if the field "QuantitéOK" is zero, for anything else, I want it visible, see the image below:

    Thank you all

    Claude from Québec, Canada


    Claude Larocque

    Sunday, October 18, 2015 2:05 PM

Answers

  • Hi Claude. Have you tried using the Format event of the Detail section? Maybe something like:

    Me.ControlName.Visible=Me.OtherControl<>0


    • Edited by .theDBguy Sunday, October 18, 2015 3:40 PM typo
    • Proposed as answer by André Santo Monday, October 19, 2015 10:12 AM
    • Marked as answer by Claude Larocque Monday, October 19, 2015 7:22 PM
    Sunday, October 18, 2015 3:11 PM
  • You could create code in the On Format event of the report section that contains the QuantitéOK text box:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Me.QuantitéOK.Visible = (Me.QuantitéOK <> 0)
    End Sub

    Detail is the name of the section in the above example, change it as needed.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, October 18, 2015 3:12 PM
  • Hi Claude.  The Format event doesn't fire in Report view. Try looking at it in Print Preview. 
    Monday, October 19, 2015 12:17 PM

All replies

  • Hi Claude. Have you tried using the Format event of the Detail section? Maybe something like:

    Me.ControlName.Visible=Me.OtherControl<>0


    • Edited by .theDBguy Sunday, October 18, 2015 3:40 PM typo
    • Proposed as answer by André Santo Monday, October 19, 2015 10:12 AM
    • Marked as answer by Claude Larocque Monday, October 19, 2015 7:22 PM
    Sunday, October 18, 2015 3:11 PM
  • You could create code in the On Format event of the report section that contains the QuantitéOK text box:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Me.QuantitéOK.Visible = (Me.QuantitéOK <> 0)
    End Sub

    Detail is the name of the section in the above example, change it as needed.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, October 18, 2015 3:12 PM
  • Hi DB guy,

    Same result for your code:

    Seems easy but it is not

    Thanks for your time


    Claude Larocque

    Monday, October 19, 2015 11:45 AM
  • Hi Hans, thank you for taking the time to help..

    It didn't work, here is the result:

    But we are on the right track, shouldn't be that hard but it is :)


    Claude Larocque

    Monday, October 19, 2015 11:46 AM
  • Hi Claude.  The Format event doesn't fire in Report view. Try looking at it in Print Preview. 
    Monday, October 19, 2015 12:17 PM
  • Thanks for the last comment DB guy, it works at first try... the Print preview fire the code...Bingo!

    Claude


    Claude Larocque

    Monday, October 19, 2015 7:22 PM
  • Thanks for the last comment DB guy, it works at first try... the Print preview fire the code...Bingo!

    Claude


    Claude Larocque

    Hi Claude. Glad to hear you got it to work. Hans and i were happy to assist. Good luck with your project.

    Monday, October 19, 2015 11:17 PM