Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Global Code (Access 2000)

    Can i make a code that makes a list box visible and makes the previous list box invisible, without referring to the particular list box? For example i have 7 list boxes and by clicking one of them, regardless
    which one, to make the previous list box invisible.Only one of the list boxes should be visible by clicking the button, and all the other list boxes should remain invisible.I
    For example if i have chosen ListBoxHouses and after that decide to click on the ListBoxRooms, the ListBoxHouses should be made invisile. t seems to me supreflous to enumerate each
    time the list boxes that must be invisible, and also it is difficult to do it.

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

    Re: Global Code (Access 2000)

    Wouldn't it be more efficient to use one list box and to change its contents as needed?

  3. #3
    Star Lounger
    Join Date
    Sep 2002
    Location
    Hastings, Sussex, England
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Global Code (Access 2000)

    Hans has provided excellent advice, but from the lack of response, I suspect that it's not what you wanted to hear.
    Since you cannot click on an invisible control, I assume that you are controlling visible/invisible from elsewhere, an option group or a series of buttons. Why not write a simple function that makes all the list boxes invisible, and then makes the required list box visible. For example, SetVisible("controlname"):

    Function SetVisible(ctlName as String)

    listbox1.Visible = False
    listbox2.Visible = False

    ctlName.Visible = True

    End Function

    There are neater ways, this is simple. Hans' solution is better.

  4. #4
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Code (Access 2000)

    Thank you Jules and Hans.I cannot populate the list boxes since they have diffrent stucture- width,columns etc. The function SetVisible(tName As String) seems to me all right, but i get the error invalid use of null.
    What may be the reason ?

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

    Re: Global Code (Access 2000)

    You'll have to provide details about your form or attach a stripped down copy of the database.

  6. #6
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Code (Access 2000)

    Thank you for the reply. I am sending the example

    kind regards

    Peljo

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

    Re: Global Code (Access 2000)

    See the attached version. The code is a little bit more complicated, because you cannot hide the control that has the focus.

    I used the double click event of the list boxes instead of the click event, because if you use the click event, the user cannot correct mistakes.

  8. #8
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Code (Access 2000)

    Thank you, Hans! works excellent

Posting Permissions

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