Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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],"")

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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:
    <pre>If Me.chkFax = True Then
    Me.txtFaxNumber.Visible = False
    Else
    Me.txtFaxNumber.Visible = True
    End If</pre>

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

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.
    Francois

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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... <img src=/S/baby.gif border=0 alt=baby width=15 height=15>

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

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

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

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

    And babies are more demanding than other users too! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •