Display multiple Combo Box Lines

B

Burt

Hi,

Not sure if I'm asking the right question, the right way.

Here it goes;

I would like to enter a character in a field and have
multiple lines display so that I can select one of them.
For example If I type in an "A" then Apple, Apron, and
Axis would appear (if I had those words in a table I was
searching). In addition, if I was to type an another
character after the "A", such as a "p", then Apple and
Apron would just appear.

I've tried different ways of trying to make this happen.
Such as trying to link a Text Box with a List Box, and
looking for an option that would display multiple lines in
a Combo Box with no luck.

Hopefully, I made myself significantly clear for a
response from someone.

Thanks for any help,

Burt
 
S

Sandra Daigle

Hi Burt,

This should be standard behavior for a combo. I think you might want to
invoke to dropdown method of the combo to *see* the list. You can use the
enter event of the combo and add this line:

me.MyCombo.dropdown

To do this with a textbox and listbox just add a textbox just above the
listbox - add this code to the change event for the textbox (adjust control,
field and table names for your project):

Private Sub Text6_Change()
Const strBaseSQL As String = "Select Custid, Custname from Customer "
Me.txtSQL = strBaseSQL & "Where Custname like """ _
& Me.Text6.Text & "*"" Order by Custname;"
Me.List2.RowSource = Me.txtSQL
End Sub

or to position (rather than filter)

Private Sub Text6_Change()
Dim inti As Integer
Dim fEnd As Boolean
inti = 0

Do Until fEnd
If Left(Me.List0.Column(1, inti), Len(Me.Text6.Text)) = Me.Text6.Text
Then
fEnd = True
Me.List0.SetFocus
Me.List0.ListIndex = inti
' put focus back to the textbox
Me.Text6.SetFocus
Me.Text6.SelStart = Len(Me.Text6 & "")
Else
inti = inti + 1
If inti > Me.List0.ListCount Then
fEnd = True
End If
End If
Loop

End Sub
 
B

Burt

Sandra,

Thanks. I knew it had to do with the combo box. I just
couldn't find the right statement.

You save me a lot of time and at least one brick wall.

Burt
-----Original Message-----
Hi Burt,

This should be standard behavior for a combo. I think you might want to
invoke to dropdown method of the combo to *see* the list. You can use the
enter event of the combo and add this line:

me.MyCombo.dropdown

To do this with a textbox and listbox just add a textbox just above the
listbox - add this code to the change event for the textbox (adjust control,
field and table names for your project):

Private Sub Text6_Change()
Const strBaseSQL As String = "Select Custid, Custname from Customer "
Me.txtSQL = strBaseSQL & "Where Custname like """ _
& Me.Text6.Text & "*"" Order by Custname;"
Me.List2.RowSource = Me.txtSQL
End Sub

or to position (rather than filter)

Private Sub Text6_Change()
Dim inti As Integer
Dim fEnd As Boolean
inti = 0

Do Until fEnd
If Left(Me.List0.Column(1, inti), Len(Me.Text6.Text)) = Me.Text6.Text
Then
fEnd = True
Me.List0.SetFocus
Me.List0.ListIndex = inti
' put focus back to the textbox
Me.Text6.SetFocus
Me.Text6.SelStart = Len(Me.Text6 & "")
Else
inti = inti + 1
If inti > Me.List0.ListCount Then
fEnd = True
End If
End If
Loop

End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Hi,

Not sure if I'm asking the right question, the right way.

Here it goes;

I would like to enter a character in a field and have
multiple lines display so that I can select one of them.
For example If I type in an "A" then Apple, Apron, and
Axis would appear (if I had those words in a table I was
searching). In addition, if I was to type an another
character after the "A", such as a "p", then Apple and
Apron would just appear.

I've tried different ways of trying to make this happen.
Such as trying to link a Text Box with a List Box, and
looking for an option that would display multiple lines in
a Combo Box with no luck.

Hopefully, I made myself significantly clear for a
response from someone.

Thanks for any help,

Burt

.
 
Top