Go to Item in Drop Down List

L

Lana

Hi all,

I need to set OnEnter of my Combo "Project1" to get the value from Text70
and then dropdown (so that i am automatically scrolled down the list to the
items which start with letters same as Text70)

I tried
Me.Project1 = Me.Text70
but it would call the value of the ProjectID column (which is invisible); so
the visible part of Combo "Project1" reflects absolutely different text from
the one in Text70.

Can anybody help me how to fix it?
Thanks in advance.
Lana
 
N

Nick 'The database Guy'

Hi Lana,

Try:

Me.Project1.Column(x) = Me.Text70

Where x is the number of the column (minus 1) that the text that you
want displayed is in.

Good luck,

Nick
 
L

Lana

Me.Project1.Column(1) = Me.Text70 would give error and ask to debug.... :(

Thank you.
Lana
 
N

Nick 'The database Guy'

Sorry Lana,

The most obvious thing to try is change Me.Text70 to Me!Text70 if that
does not fix it then email me with the error message.

Good luck,
 
D

Douglas J. Steele

While you can set what's displayed in a combo box by setting its value, you
can't do that using the Column collection.

What you can do is loop through all of the items in the combo box, comparing
what's in Column(1) to what's in the text box until you find the row with
that value. To select that row, you'd set the combobox equal to what's in
the BoundColumn of the row. Something like:

Dim intLoop As Integer

Me.Project1 = Null
For intLoop = 0 to Me.Project1.ListCount
If Me.Project1.Column(1, intLoop) = Me.Text2 Then
Me.Project1 = Me.Project1.Column(Me.Project1.BoundColumn - 1, intLoop)
Exit For
End If
Next intLoop

(Obviously, if you know what the bound column is, you can substitute the
constant for Me.Project1.BoundColumn - 1 above)
 
L

Lana

Hi Douglas,

I am really stupid when comes to coding. I wanted to try the one you have
given me as it is, but then i realized that Me.Project1.Column(1) cannot be
equal to Text70. It is only equal in the 1st 3 digits. Wouldn't that make any
difference?

At first i had an idea of using the "SendKeys" for that, but dont know how
to and besides i've heard it is not a very advisable function to use... Feels
really frustrated... It seemed to be such a simple task...

PLEASE!!!!! Can you help me with this one? I am lost!

Lana
 
D

Douglas J. Steele

Sorry, not sure whether you're saying that the first 3 characters
Me.Project1.Column(1) need to be equal to Text70, or the first 3 characters
of Text70 need to be equal to Me.Project1.Column(1)

For the first, use

If Left$(Me.Project1.Column(1, intLoop), 3) = Me.Text2 Then

For the second, use

If Me.Project1.Column(1, intLoop) = Left$(Me.Text2, 3) Then


My advice is never use SendKeys!
 
Top