Get information from selected item of ListBox (1 Viewer)

Surka

IT dude
Local time
Today, 17:03
Joined
Aug 5, 2013
Messages
41
Dear Santa,

from a search form example I got from this forum I made the following:

  • A listBox which shows results as you type, using a query.
This listBox has 1 column, I need it that way.

What I need is to show the information from the selected item of the listBox on a textBox, getting this info from the results of the query.

I found 2 answers which I don't like:

1- =DLookUp("[Column]","[Query]") as source of textBox
This shows only information from the first row. So if you select the second result from the listBox, it still shows the first row.
2- =SearchResults.column(int) as source of textbox
It does not work, because listBox has only 1 column.
Meanwhile I will continue searching, and the question:
Could you please help me with another solution?

Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:03
Joined
Aug 30, 2003
Messages
36,124
Why not include the other columns in the listbox but hide them, and use method 2?
 

Surka

IT dude
Local time
Today, 17:03
Joined
Aug 5, 2013
Messages
41
I tried that option but it did not work. I will try again because you name it.
 

Surka

IT dude
Local time
Today, 17:03
Joined
Aug 5, 2013
Messages
41
I realized I was adding fields onto the Query, and not on the query based listBox. Now it works, but it is difficult to add as many textbox as field are, and adding the code: =[SearchResults].[column](0) to each textbox. I do not know what column number is for each field.

Is there a tidier way of doing this? Adding as many textbox as columns on the listBox are.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:03
Joined
Aug 30, 2003
Messages
36,124
The column numbers are in the order of the fields in the SELECT statement, starting with 0.
 

Users who are viewing this thread

Top Bottom