• when is a listbox not selected ? (access97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » when is a listbox not selected ? (access97)

    Author
    Topic
    #365353

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

    Viewing 0 reply threads
    Author
    Replies
    • #563689

      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.

      • #563693

        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)

        • #563704

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

          • #563709

            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

            • #563716

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

            • #563717

              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)

    Viewing 0 reply threads
    Reply To: when is a listbox not selected ? (access97)

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

    Your information: