Multi Select List Box to Text Box problem

indesisiv

Access - What's that?
Local time
Today, 22:31
Joined
Jun 13, 2002
Messages
265
I am using access 97 and am having a minor problem with a list box.

I have a multi select list box that as each item is selected places that into a text box. This is only there to allow the user to input the data without typing.

I am using the following code:
Private Sub lst1_AfterUpdate()
Dim ISel As Integer, I As Integer
Dim listvalues
listvalues = ""
ISel = 0
With lst1
For I = 0 To .ListCount - 1
If .Selected(I) Then
listvalues = listvalues & ". " & Me.lst1.Column(0, I)
ISel = ISel + 1
End If
Next I
End With

Me.txtList = listvalues
End Sub



What i need it to do is. ...
1) Auto resise the text box to fit the number of rows of information.
2) Bullet point the information in the text box.


Any help will be gratefully recieved

Steve
 
Is this possible ???
If not is any of it possible?

Thanks
Steve
 
I believe this might actually be possible, but I've never done it. Check out the Access 2000 Developer's Handbook, Chapter 8, on resizing forms. They also discuss resizing controls. It may have what you need. However, I think most of the underlying code is on the CD, so you must actually buy or borrow the book and CD to use their technique.

I had form situation similar to yours and solved it using a second list box instead of a text box to display selected values. I use command buttons to move items between the "available" and the "selected" items. This way, you're also certain that only one item will be on each line. With a text box, you might be weird text wrapping if some items are longer/shorter than others.
 
Try this.

For I = 0 To .ListCount - 1
If .Selected(I) Then
listvalues = vbcrlf & chr(146) & listvalues & ". " & Me.lst1.Column (0, I) ' could also try (176) or (186)
ISel = ISel + 1
End If
Next I
me.TextBox.height = (225 * .listcount-1) '225 ~8 point Tahoma
End With

You have to remember to allow space for the textbox to grow but I also have seen an example for moving / resizing form controls etc in response to screen resolution (but for the life of me cannot remember where - I shall have a look)
 
Last edited:
Thanks

Cheers Fizzio it works like a charm.

Had to change it a little but thanks for the prod in the right direction.

Private Sub lst1_AfterUpdate()
Dim ISel As Integer, I As Integer
Dim listvalues
listvalues = ""
ISel = 0
With lst1
For I = 0 To .ListCount - 1
If .Selected(I) Then
listvalues = listvalues & Chr(149) & Me.lst1.Column(0, I) & vbCrLf
ISel = ISel + 1
Me.txtList.Height = (225 * ISel) '225 ~8 point Tahoma
End If
Next I

End With

Me.txtList = listvalues
End Sub


Sorts it out.

Steve
 

Users who are viewing this thread

Back
Top Bottom