Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    when is a listbox not selected ? (access97)

    I have a textbox and two listboxes on a form.

    i have coded the textbox and the first listbox together so that typing a publisher name in the textbox moves down the list in the listbox to similar entries.

    the two listboxes are coded together so that when i click in the first (eg. publishers) the second fills with a list of publications

    why doesnt the coded movement in the publishers listbox (carried out by the textbox_change) trigger the action in the second (publications) listbox ?

    calling the procedure by name shows that the publishers listbox default value has remained at null when the textbox_change runs but the default value is set correctly by clicking. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  2. #2
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    Why are you talking about default values?
    To make it work you would have to use the textbox AfterUpdate event to assign a value to the publishers listbox corresponding to the publisher, and then call the Click event (publishers listbox) in order to fill the publications listbox, assuming you are using this to fill the publications listbox.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    the default value that i refer to is the value that you get when you use 'me.mylistbox' rather than 'me.mylistbox.value'

    as i said, calling the Click event of the publisher listbox causes an error because the listbox does not have a value even though the user has typed the value into the textbox and the correct item in the publishers listbox is selected (highlighted but obviously not in memory somewhere)

  4. #4
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    How did you code the textbox and the first listbox together ? And how do you move down the publishers listbox ?

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    the textbox has an onchange procedure that loops down the listbox looking for matches in the bound column ( an integer between 0 and about 600). When it finds a match it selects the item with the line mylistbox.selected(x) = true
    i am not interested about being exact with this - they type it in to find a place in the list. It is there for user convenience so they can get down the list quickly but more accurately than scrolling (list box is quite shallow). what i want though is to get the value of the row selected in the above code extract into the listbox 'default value' so that i can then call the onclick event to populate the next listbox with the publications of this publisher.

    code extract :

    For x = 0 To .lstPubs1.ListCount
    If Left(.lstPubs1.ItemData(x), Len(.txtPubs1.Text)) = .txtPubs1.Text Then
    .lstPubs1.Selected(x) = True
    lstPubs1_Click '## this procedure fails because the lstpubs1.value is null ##
    Exit Sub
    End If
    Next x

  6. #6
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    In order for you to use the Click event you must set the value of the listbox - selecting the correct row is not sufficient.

  7. #7
    Star Lounger
    Join Date
    Dec 2001
    Location
    Fredensborg, Denmark
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: when is a listbox not selected ? (access97)

    By the way. Why don' t you consider using a combobox as a substitute for the txtBox and the publishers listbox? I have attached a small sample (ver. 97)
    Attached Files Attached Files

Posting Permissions

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