Solved Listbox data not displaying when adding items to a destination Listbox

bmaccess

Member
Local time
Yesterday, 21:36
Joined
Mar 4, 2016
Messages
97
Hi there.

I need some help please. The Item in the SearchList must be added to the Destination list but only the field name appears but no the data. Any suggestion how to solve the problem please.

Thanks

If SearchList.ListCount > 0 Then

' Build a comma-delimited string with all columns of the first row

firstItem = ""

For i = 0 To SearchList.ColumnCount - 1

If i > 0 Then firstItem = firstItem & ","

firstItem = firstItem & SearchList.Column(i, 0)

Next i



' Add the constructed string to the destination listbox

destListbox.AddItem firstItem

End If

View attachment 117584
 
Last edited:
So everytime I search the result must be added to the destination Listbox
Please remember that we are not familiar with your database, so what may be obvious to you may not be clear to some of us. I don't see a "search" box in your images. How exactly do you do the search?
 
Hi there. The results of the search is in the bottom listbox where the font is bold. The search part is sorted. I only need to move the first element to the destination listbox which is above it.
Are you not able to post a sample db? It might be easier to solve the problem if you could.
 
It looks like whatever you are doing works but it is moving the first line, in your case the Column Heads, instead of the record.
Try it with column head property set to no.
 
Have you even tried just walking that very small snippet of code?
 
firstItem = firstItem & SearchList.Column(i, 0)

It looks like you are going through just the very first entry in your SearchList, column by column.
How are you getting the next row? Also, are you trying to get the next selected row?

From you code, I'm not sure exactly what you are TRYING to do as your code ONLY goes column by column through the first ROW.
I also can't tell if the header in your SearchList is data (which this seems to indicate) or the actual headers as I can't see your form.

I also can't tell what you are actually trying to do as it seems you are just adding items from one list to another, but you haven't given a business reason to make a duplicate of an existing record set, nor have you given us enough information to know how you are loading your source listbox.
 
firstItem = firstItem & SearchList.Column(i, 0)

It looks like you are going through just the very first entry in your SearchList, column by column.
How are you getting the next row? Also, are you trying to get the next selected row?

From you code, I'm not sure exactly what you are TRYING to do as your code ONLY goes column by column through the first ROW.
I also can't tell if the header in your SearchList is data (which this seems to indicate) or the actual headers as I can't see your form.

I also can't tell what you are actually trying to do as it seems you are just adding items from one list to another, but you haven't given a business reason to make a duplicate of an existing record set, nor have you given us enough information to know how you are loading your source listbox.
Thanks problem solved
 
Not producing what you want I believe?
Thanks problem solved
Well please tell others how, or show the working code.
I know what the issue is, but it could help someone else later on?
After all that is what these forums are for helping others, not just yourself. :(
 
Not producing what you want I believe?

Well please tell others how, or show the working code.
I know what the issue is, but it could help someone else later on?
After all that is what these forums are for helping others, not just yourself. :(

firstItem = firstItem & SearchList.Column(i, 0)

We just had to change the 0 to a 1

firstItem = firstItem & SearchList.Column(i, 1)


End Sub
 

Attachments

Last edited:
I have posted the solution database
Does not work for me, unsless I misunderstood you? :unsure:
The -1 values were what I meant when I said 'Not producing what you want I believe?'
1734783546930.png
 

Users who are viewing this thread

Back
Top Bottom