Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    aftermath of forcing listbox selection (A2k3 SP2)

    Hi All,
    I've got a combobox and 2 listboxes on a simple pop-up form (no subforms). As can be seen from the following code (error handling omitted), that I am using the AfterUpdate event to fill the 2 listboxes, both have MultiSelect set to none. Only very rarely do the 2 listboxes have more than 1 selection, so I was asked to "pre-select" that only selection on both listboxes, hence the .Selected(0).
    My problem is that when I try to click on anything after this, the values pre-selected in the listboxes disappear on MouseDown, re-appear on MouseUp and the focus stays on the combobox, effectively locking all the other controls on the pop-up form. The combobox itself is not locked, I can change its' value. I've tried to SetFocus on another control and I get "Error 2110: MyDB can't move the focus to the control MyControl".
    So again, I'm missing something and need help finding it.

    Thank you.

    <pre>Private Sub cboOldIndex_AfterUpdate()

    Dim strOrgSource As String
    Dim strFundSource As String

    strOrgSource = "SELECT DISTINCT [Org] "
    strOrgSource = strOrgSource & "FROM tblAccountsTable "
    strOrgSource = strOrgSource & "WHERE [Index] = '" & Me!cboOldIndex & "'"

    strFundSource = "SELECT DISTINCT [Fund] "
    strFundSource = strFundSource & "FROM tblAccountsTable "
    strFundSource = strFundSource & "WHERE [Index] = '" & Me!cboOldIndex & "'"

    Me.lstOldOrg.RowSourceType = "Table/Query"
    Me.lstOldOrg.RowSource = strOrgSource
    Me.lstOldOrg.Selected(0) = True

    Me.lstOldFund.RowSourceType = "Table/Query"
    Me.lstOldFund.RowSource = strFundSource
    Me.lstOldFund.Selected(0) = True

    End Sub
    </pre>

    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

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

    Re: aftermath of forcing listbox selection (A2k3 SP2)

    Use the following instructions to select the first item in the list boxes:

    Me.lstOldOrg = Me.lstOldOrg.ItemData(0)

    Me.lstFundOrg = Me.lstOldFund.ItemData(0)

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: aftermath of forcing listbox selection (A2k3 S

    Thank you Hans,
    Now that I see this I'm guessing that Selected is only to be used with multiselect set to simple or extended?
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

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

    Re: aftermath of forcing listbox selection (A2k3 S

    Yes. With a single-select list box, you set or inspect the Value property (this is implicit in the instructions I posted).

Posting Permissions

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