Text box displaying a list box item

elite311

Registered User.
Local time
Today, 07:12
Joined
May 21, 2010
Messages
18
I have a form that is displaying info about a tech from a table when the tech is selected from a list. I have everything working fine except the info feild. This field has alot of info written in it on the table so when I use a list box to call it up I only get a little but of the info displaying. What I'm wondering is if there is a way to have a text box display the first item(Only is one item) of the list box so I can read all the info un the text box and then hide the list box.
 
Not 100% sure what you mean but see if this helps:
You can display more than one colomn in the listbox to cater for more info about the Tech. Look at the Format properties of the Listbox and set the number of colomns you want to show based on the query it is pointing to.
You could then size the listbox to "look" like a one-liner textbox.
 
I tried that but the problem is you cant wrap the text in a list box so instead of the text wraping down to the next line it just cuts off at the end of the feild size. I was thinking if I had the list box and made it not visible then I could use a text box to display the info from the list box andit would wrap acording to the feild size I choose so I could read it all.

So text1 control source would be:
=listbox1

this works if I read from another text box but I`m not sure how to do it from the list box. I was thinking it might be something like this:

textbox1.text = listbox1.text

I`m thinking I have to tell the text box to read the frist item of the list box as it`s control source but I`m not sure if it can even be done
 
Well I could make your idea work, but it would not be the best way to do it as some guys will frown upon it :)
But here goes, just to show you it is possible:
Set the textbox source to:
listbox1.colomn(0) & " " & listbox1.colomn(1)

No to get past the fact that at least a line in the listbox must be selected before for it will show, put this line in the OnOpen event or somewhere:
Me.Listbox1.Selected(0) = True 'This would select the 1st line (count starts at 0

Now you can set listbox1.visible = false
Size your textbox to wrap as per your needs.

A better way would however be to use DLookup.
If you never worked with DLoopup (and the other D functions, then read up on them as they will open a new world to you).

textbox1 = DLookup("Field","Table/Query","Criteria")

"Criteria" is optional, if you leave it out it will show the 1st line of the query, which in this case is exactly what you want to see.
 
Last edited:
Thanks!

The DLookup thing sounds very interesting I will read more on it. But seeing as I know nothing about it. Can the DLookup be dependent on what is selected in the TechName list box? then only show the TechInfo for the selected Tech?

I am not quite sure how to use that function. I am going to start searching that now
 
DLookup is absolutly brilliant, also read up on DSum and DCount. I use them all the time.
The same way you base a listbox on a query, you can base a textbox on a DLookup "query". I find it easier to do than to code a SQL syntax.

Let me try and give you an example:
Say you have a query called MyQuery with 2 fields: Field1 and Field2

You already know how to base a Listbox on that query and to show both Field1 and Field2 by setting the Format colomn numbers to show to 2.

Now with a textbox you would would do it like this:

Textbox1 = DLookup("Field1","MyQuery") & " " & DLookup("Field2","MyQuery")

Play around and let me know
 

Users who are viewing this thread

Back
Top Bottom