none
Using a VBA If statement in a Report RRS feed

  • Question

  • Hi

    I am trying to use an IF statement which works in a form but when I try and run it in a report it come up with the error:

    Run-time Error '2427':

    You entered an expression that has no value.

    The code for this is as follows:

    If Me.Web_Blocks_Applicable = "Yes" Then
       Me.TS_Web_Blocks_Channels_Accept.Visible = True
       Me.WebBlocksLbl.Visible = True
    Else
       Me.TS_Web_Blocks_Channels_Accept.Visible = False
       Me.WebBlocksLbl.Visible = False
    End If

    Me.Web_Block_Applicable contains either a "Yes" or a "No" and is a text field.

    I cannot figure out why this would not work as it works in the form.

    Can anyone help?

    Thanks

    AJ

    Wednesday, September 26, 2018 10:46 AM

Answers

  • What Access version?

    In mine (2013+), this is possible:

    • Marked as answer by AJCB Wednesday, September 26, 2018 3:53 PM
    Wednesday, September 26, 2018 1:59 PM

All replies

  • hmm, why not using conditional formatting?
    Wednesday, September 26, 2018 12:02 PM
  •  I can't really do conditional formatting because there is no way of changing one fields formatting based on the result in another field. 
    Wednesday, September 26, 2018 1:13 PM
  • What Access version?

    In mine (2013+), this is possible:

    • Marked as answer by AJCB Wednesday, September 26, 2018 3:53 PM
    Wednesday, September 26, 2018 1:59 PM
  • Thanks guys.  I found the solution using a combination of Conditional formatting and iif statements to show N/A instead of hiding.  Still bugging me that I can't make them invisible but it'll be fine.

    Access 2016 by the by Stefan.   


    • Edited by AJCB Wednesday, September 26, 2018 3:55 PM
    Wednesday, September 26, 2018 3:54 PM