ListBox column is null

soulice

Registered User.
Local time
Today, 17:04
Joined
Dec 21, 2011
Messages
41
I have a listbox filled form a query. It has 4 columns. I want the value from the last column and use it to open a report. I can open a report ok, the issue is that
Me.lstThings.Column(3) is always null. Read a stack of posts out here and appear to be doing it right. What am I missing?
 
How exactly did you determine that that value is null? And what is the column count of the listbox?
 
I am debugging, then stepping through. ColumnCount comes out to 4.
 
Did you select a row in the listbox before calling the code?
 
Yes, I am doing this on the DblClick action...
 
Try it on the Click event. If you're not having luck upload a cutdown version of your db so we can see what you're doing.
 
Does your line of code look something like this??
Code:
Me.lstThings.Column(3, lstThings.ItemsSelected)
 
Here it is:
DoCmd.OpenReport "IndividualReport", acViewPreview, , "[IndividualReport_ID]= " & Me.lstThings.Column(3, lstThings.ItemsSelected)

returns null on DblClick. OnClick does nothing.
 
ItemsSelected requires an INDEX

Me.lstThings.ItemsSelected(x)

where x is the row.

If you don't have it set to be multiselect then you can just refer to the column

"[IndividualReport_ID]=" & Me.lstThings.Column(3)

If your list box is multiselect then you would not be able to do it this way anyway so you would need to iterate through the ItemsSelected to build an IN Clause.
 
Multiselect is set to none. I must have another setting wrong as Me.lstThings.Column(3) is Null as well. I would like to post a sample db, but it has too much proprietary stuff to trim it down and post.

Edit: just noticed (not sure why I didnt see this before) that when I select any row, it is not acutally selecting the row. The first row appears to get focus, but always returns null.
 
Last edited:
Fixed it. I had the listbox bound to a field. Once I removed the binding, all was well. Thanks all. Be back shortly with more questions! :)
 

Users who are viewing this thread

Back
Top Bottom