1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

MS Access - Displaying control only when checkbox clicked

Discussion in 'Business Applications' started by soyuz02, Aug 7, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. soyuz02

    soyuz02 Thread Starter

    Joined:
    Aug 7, 2006
    Messages:
    17
    Hi,

    I have a form with an option group. Now i have a control box which i only want to be shown when a specific option from that option group is checked. Is this possible?

    Thanks!
     
  2. Chris_E

    Chris_E

    Joined:
    Feb 16, 2006
    Messages:
    360
    Yeah, possible.

    Say your Frame box has 3 options. Each will be assigned a value (say 1,2 and 3), then, using VBA, you can create a procedure that goes something like this:

    Private Sub MyFrame_Click()

    Dim Frame_Value As Integer
    Frame_Value = Me.MyFrame.Value
    Select Case Frame_Value
    Case 1, 2
    Me.MyTextbox.Visible = True
    Case 3
    Me.MyTextbox.Visible = False
    End Select
    End Sub

    This will make the text box hidden only when option 3 is selected but it will be visible when 1 or 2 is selected.

    Don't forget to give the textbox a default visibility. In other words, if it should normally be hidden and only shows when the appropriate option is ticked, tehn its default visibility should be .visible=No.

    Hope this helps

    Chris
     
  3. soyuz02

    soyuz02 Thread Starter

    Joined:
    Aug 7, 2006
    Messages:
    17
    Thank you so much, worked like a charm!
     
  4. Chris_E

    Chris_E

    Joined:
    Feb 16, 2006
    Messages:
    360
    Good stuff!

    Why not mark this as "Solved"

    Under "Thread Tools", pull down and select it.

    Pleased I was able to help

    Chris
     
  5. soyuz02

    soyuz02 Thread Starter

    Joined:
    Aug 7, 2006
    Messages:
    17
    However, when I complete a record in which I select the checkbox that displays the text control, when I then create a new record, the text control is shown by default since it was there from the previous record. Any fix to this???

    Thanks!
     
  6. Chris_E

    Chris_E

    Joined:
    Feb 16, 2006
    Messages:
    360
    What I'd do is first decide what the "deafult" state needs to be (for the control that is made visible when you select the associated option) when you open the form.

    When you have that in your sights, you can set it by creating an OnLoad procedure for the form...

    Select the form...
    View the properties and click the "Event" tab and then drill down to the "On Load" entry. Click the ... (ellipsis) button on the right of the entry to open the Code Builder for OnLoad for your form.

    In this routine, use a command like:

    Me.MyControl.Visible=False

    This will ensure the control is always hidden when you load up the form.

    Also, you should copy this command and use it for the "On Current" event.

    Now, when you move from record to record, the code will hide the control if it was revealed in the previous record.

    Hope this helps. If so, great! If not, come back again!

    Cheers

    Chris
     
  7. soyuz02

    soyuz02 Thread Starter

    Joined:
    Aug 7, 2006
    Messages:
    17
    Thanks Chris. However what happens now is that when I browse through existing records which have an option selected that displays the text box, it is not visible until I click on the option from the group which displays it. Any ideas?
     
  8. Chris_E

    Chris_E

    Joined:
    Feb 16, 2006
    Messages:
    360
    Ok, how we do this depends on what the Form looks like (Contiunous form or Single Form). So I can see how your form is structured and behaves, it woild be helpful to see it.

    If you are able to make a copy of it, take any sensitive data out, and ZIP it up, you can post it here as an attachment. I'll be happy to take a peep and provide some answers.

    Then, rather than fix it for you, I can tell you how to fix it and you can do it yourself, if that's ok?

    Chris
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/490118

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice