Change Combo box values depending on values in text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a text box that has an input mask (>LLL\ 0000;0;_ displays as "GLN
0123" for example). The first three letters of the text box indicate a region
of the UK, e.g. GLN = Greater London, ESX, HER, STA, BED (and about 30
others) = SOUTH, and GWT, HUM, DUM, (and another 20-30) = NORTH.

The combo box contains: GLN, SOUTH, NORTH.

What i would like is for the combo box to be automatically populated with
GLN, SOUTH, and NORTH when the first three letters of the text box are
entered with the same prefixes. The 4 numbes after don't matter.

I have tried doing this in the onChange event in the text box, but i can
only do it for the whole input mask, i.e. "GLN 0123" would bring up "GLN" in
the combo box, but as there are thousands of different GLN's, this would
obviously become very unmanageble and long!

How can i only use the first three letters prefix of the text box?

Im ok in VB, but not advanced by any means.

Thanks in advance!

Remy
 
Well, i am not sure what are you doing with combobox, here how i understand:

Sub MyTextbox_AfterUpdate()

me.MyCombo.rowsource = Left(me.MyTextbox, 3) & ";SOUTH;NORTH"

end sub

in this case MyCombo should have rowsourcetype=Value list

HTH
 
Alex,

This works in its own way, but what i want is for the combo box to display
"SOUTH" if the first three letters are for example "HER", "NORTH" if the
letters are "DUM", or "GLN" if they are "GLN". At the moment, the combo box
contains GLN, NORTH, SOUTH in its value list. I want them to automatically
selected when the 3 letters are entered.

The code you have given shows the first three letters, and then adds North
and South. I just the approriate region, not the three letters i have entered.

Hope this clarifies it a bit, I could do with the solutions,

Thanks in advance!
 
Hi,
then you can write something like this:

select case Left(me.MyTextbox, 3)
case "HER"
me.MyCombo="SOUTH"

case "DUM"
me.MyCombo="North"

case "GLN"
me.MyCombo="GLN"
end select
 
Thats Great, Thanks!

Alex Dybenko said:
Hi,
then you can write something like this:

select case Left(me.MyTextbox, 3)
case "HER"
me.MyCombo="SOUTH"

case "DUM"
me.MyCombo="North"

case "GLN"
me.MyCombo="GLN"
end select
 
Back
Top