Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box Code

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
I'm having issues with the following code that works on a command button but not on the after update of the list box. I really need it attached to the after update listbox. Any ideas what I'm missing?

Code:
Private Sub lstOrgRes_AfterUpdate()
    
Dim ctlOrgReg As Access.Control

Set ctlOrgReg = Me.lstOrgRes

If ctlOrgReg.ItemsSelected.Count > 0 Then
    MsgBox "w00t"
Else
    MsgBox "BS"
End If
    
End Sub
 
Please, define "not works"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
after an item is selected from the list box and the After Update event is fired, it is not recognizing that an item was selected and returns the mesage box, "bs".
 
Is the ListBox multi-select ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
nope, it's a single select list box. And let me go into a little detail of what I'm up against.

The list box is populated with a listing of values found in a table. One of the items can be a Null value.

If I use a statement that says,

Code:
 if isNull(me.lstOrgRes) = False

I would get a false positive when a user selects the null value in the select box.

Hope that helps a little.
 
nope, it's a single select list box
So, your code works as expected.
Typed, untested:
Code:
Private Sub lstOrgRes_AfterUpdate()
If Me!lstOrgRes.ListIndex >= 0 Then
    MsgBox "w00t"
Else
    MsgBox "BS"
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top