• Hiding certain info using checkboxes (Access 2002, SR 1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Hiding certain info using checkboxes (Access 2002, SR 1)

    Author
    Topic
    #371517

    I have a query that list contact information for our customers with checkboxes showing (True = yes, false = no) whether they want specific contact information to be published and be distributed among our customers. For example, John Doe wants only address and home phone listed but not his fax number or Email address.

    I’m trying to figure out how to show information that each customer wants to be published via code in a report I’m creating. Obviously, I can’t use queries because I need to show all customers that wants to be published, but with specific information rather than all information.

    TIA.

    Brent

    Viewing 1 reply thread
    Author
    Replies
    • #590734

      This might be too simplistic for your needs (depending on how you want to format your report), but you could use calculated fields either in the report or in the underlying query everywhere you want to “censor” data, e.g.

      =iif([AddressOK],[Address],””)

    • #590735

      If you want to do this in a report, it easy.
      In the On Format event of the detail section of the report, enter the following:

      If Me.chkFax = True Then
         Me.txtFaxNumber.Visible = False
      Else
         Me.txtFaxNumber.Visible = True
      End If

      This suppose you have a checkbox chkFax and check it to hide the faxnumber.

      • #590742

        I had tried this before giving up and posting the question. The only difference is that I didn’t include Me.xxx

        What I had did was:

        If ListAddress = True Then
        txtAddress.Visible = True
        Else txtAddress.Visible = False

        What happened was ALL address fields were blank!

        I guess I should have included Me.xxx

        Thanks.

        • #590746

          Are you sure that you put the code in the On Format event of the Detail section and not in the On Open report.
          And use the same syntax structure as in my sample.

          • #591038

            Darn. I forgot to warn you that I have 4 checkboxes to deal with: ListAddress, ListHPhNbr, ListEmail and ListFax.

            I have no clue how to “nest” IF statements? I wanted something like:

            If Me.ListAddress = False Then
            Me.txtAddress.Visible = False
            Else
            Me.txtAddress.Visible = True

            If Me.ListHPhNbr = False Then
            Me.txtHPhNbr.Visible = False
            Else
            Me.txtHPhNbr.Visible = True
            .
            .
            .
            End If

            And I receive an error message saying that I need an End If to close If block. I can’t seem to figure out how to use ElseIf properly because if I do, then if one record wants to hide address, then it hides rest of records’ addresses because now, the control is set to Not Visible. This is bad….How do I use If…Else…ElseIf…Else?

            • #591083

              Check boxes are independent of each other. So you don’t want to use ElseIf here. Just repeat If … Then … Else … End If for each checkbox.

              But, I think you can do without the If construction. Since the Visible property should be True if the check box value is True and False if the check box value is False, you can use:

              Me.txtAddress.Visible = Me.ListAddress
              Me.txtHPhNbr.Visible = Me.ListHPhNbr
              Me.txtEmail.Visible = Me.ListEmail
              Me.txtFax.Visible = Me.ListFax

            • #592542

              Sorry for not replying. I just had a baby girl and now, I’m taking couple of weeks off and today’s my last day of regular work.

              I’ll get back to you as soon as I can… baby

            • #592608

              Congratulations! Don’t hurry, taking care of the baby is more important than check boxes in Access.

            • #592626

              And babies are more demanding than other users too! smile

    Viewing 1 reply thread
    Reply To: Hiding certain info using checkboxes (Access 2002, SR 1)

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

    Your information: