• Checkboxes Again (A2K)

    Author
    Topic
    #367680

    In a report I’m displaying a checkbox with the data name being OwnSVF and the checkbox name being cbS. All I’m trying to do within the report is have the checkbox display only when it is equal to -1. I’ve tried variations similar to:
    IIf ([OwnSVF] = -1), cbS.Visible = True, cbS.Visible = False
    and was laughed at by Access. Any suggestions or am I barking up an unclimbable tree? Thanks in advance for any help.

    Viewing 3 reply threads
    Author
    Replies
    • #574034

      Why did Access laugh at you, what was the error message?
      I don’t think your command is correct.
      Are you coding this in VBA?
      HTH
      Pat

    • #574042

      Where are you putting your code? I think that it needs to be in the Detail-Format, Something like

      Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
      If me![OwnSVF] = -1Then
      cbS.Visible = True
      else
      cbS.Visible = False
      End If
      End Sub

      HTH

      Peter

      • #574062

        As always the friendly Woody loungers come through. I promise to be less cute and more clear in the future when airing out my Access problems. In this particular case, I had the right idea with respect to the code needed, but applied it in the wrong place. Thanks again to all of you folks who jumped in.

        Andy

    • #574043

      Bat17 is correct…the code must be in the On Format event of the appropriate report section (Header, Detail, etc.).

    • #574078

      Hi Andy,
      Just for future reference, your original error was down to the way you were trying to use IIf. The IIf function returns a value, it doesn’t perform an action. You could have used it like this:
      cbS.visible = iif([OwnSVF]=-1,True, False)
      because that way the IIf function is returning either True or False, it’s not attempting to assign the value to anything. Otherwise, you have to use the If…Then..Else syntax suggested previously.
      I hope that makes sense.

      • #574163

        Rory:
        Thanks for taking the time to offer the extra help. I’ll use your variation on this code to see how it works for me. One of the real pluses of being in the “Lounge” is learning newer and/or better ways of doing things. Thanks again.

        Andy

    Viewing 3 reply threads
    Reply To: Checkboxes Again (A2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: