Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box initialization value

Status
Not open for further replies.

fishman13

Programmer
Jul 8, 2002
73
0
0
US
When opening the list for a combo box, is there a way to set the pointer to a certain place. For example the combo box contains a list of names from A-Z. When the list is opened I want the list to start at a particular letter based on the value in a textbox.
 
You could do something like....

<%
if rs(&quot;whateverfield&quot;).Value = &quot;Sales&quot; then %>
<select name=&quot;selectme&quot; size=&quot;1&quot;>
<option selected value=&quot;Sales&quot;>Sales</option>
<option value=&quot;Distribution&quot;>Distribution</option>
<option value=&quot;Finance&quot;>Finance</option>
<option value=&quot;Technical&quot;>Technical</option>
<option value=&quot;Manufacturing&quot;>Manufacturing</option>
</select>
<%end if%>

Best
Tom Gahagan
tgahagan@charter.net

REST



If you get a chance to sit out or dance...

I hope you dance. L Wommack
 
Oops... thought I was in the ASP forum... SORRY!! LOL!!!!!
Tom Gahagan
tgahagan@charter.net

REST



If you get a chance to sit out or dance...

I hope you dance. L Wommack
 
fishman;

When the list is opened

Tell us when the list is opened.

LoadEvent of a form....
Fired when a cmdbut is clicked....

Regards - Wayne
sig_jugler.gif
...all this and tap dancing too!
 
Fishman13:

Paste this code in your program and execute:

OTEST = CREATEOBJECT(&quot;Test&quot;)
OTEST.SHOW()
READ EVENTS

DEFINE CLASS TEST AS FORM


DOCREATE = .T.
CAPTION = &quot;Form1&quot;
NAME = &quot;Form1&quot;


ADD OBJECT COMBO1 AS COMBOBOX WITH ;
HEIGHT = 24, ;
LEFT = 108, ;
SELECTONENTRY = .T., ;
SORTED = .T., ;
TABINDEX = 2, ;
TOP = 144, ;
WIDTH = 168, ;
NAME = &quot;Combo1&quot;


ADD OBJECT TEXT1 AS TEXTBOX WITH ;
HEIGHT = 23, ;
LEFT = 108, ;
TABINDEX = 1, ;
TOP = 96, ;
WIDTH = 100, ;
NAME = &quot;Text1&quot;


PROCEDURE COMBO1.INIT
THIS.ADDITEM(&quot;Apples&quot;)
THIS.ADDITEM(&quot;Bananas&quot;)
THIS.ADDITEM(&quot;Grapefruit&quot;)
THIS.ADDITEM(&quot;Oranges&quot;)
ENDPROC


PROCEDURE TEXT1.INTERACTIVECHANGE
FOR I = 1 TO THISFORM.COMBO1.LISTCOUNT
IF LEFT(UPPER(THISFORM.COMBO1.LIST(I)),1) = LEFT(UPPER(THIS.VALUE),1)
THISFORM.COMBO1.SELECTED(I)=.T.
ENDIF

ENDFOR
ENDPROC

PROCEDURE DESTROY
CLEAR EVENTS
ENDPROC


ENDDEFINE
*
*-- EndDefine: test
**************************************************


Good luck.

Al
 
Al,

I entered the code in but the combo box still starts with Apples as being the selected. I tried to set teh value of the textbox to &quot;Orange&quot; and was trying to have the highlite bar positioned over &quot;Orange&quot;.
 
Fishman13:

The way I interpreted your requirement, without further info, was when the first character of a selection in the combobox is typed into the textbox, the respective combo item would be highlighted.

In other words, if you enter G in the textbox, Grapefruit would be selected.

Please advise your full requirement. What &quot;code&quot; are you referring to?

Al

 
I have a combo box on a form, that can be left blank or filled in with a name. The name that will be filled in is stored in another table. I was hoping to do a query on the table that contains the name and have the combo box highlite item set to that name. If I place the name or part of the name in the combo box, the user will have to clear the field if the combo box should be left blank.
 
Fishman13:

Paste this code in your program and execute. Entering a 2-char code in the textbox displays a particular record. It won't be exactly what you need to start with, but we can tailor it.

OTEST = CREATEOBJECT(&quot;Test&quot;)
OTEST.SHOW()
READ EVENTS

DEFINE CLASS test AS FORM
TOP = 0
LEFT = 0
HEIGHT = 226
WIDTH = 265
DOCREATE = .T.
CAPTION = &quot;Form1&quot;
NAME = &quot;Form1&quot;

ADD OBJECT combo1 AS COMBOBOX WITH ;
BOUNDCOLUMN = 2, ;
ROWSOURCETYPE = 2, ;
ROWSOURCE = &quot;DESC&quot;, ;
CONTROLSOURCE = &quot;TEST&quot;, ;
HEIGHT = 24, ;
INCREMENTALSEARCH = .T., ;
LEFT = 72, ;
SELECTONENTRY = .T., ;
SORTED = .F., ;
TABINDEX = 2, ;
TOP = 60, ;
WIDTH = 168, ;
NAME = &quot;Combo1&quot;


ADD OBJECT text1 AS TEXTBOX WITH ;
HEIGHT = 23, ;
LEFT = 72, ;
TABINDEX = 1, ;
TOP = 24, ;
WIDTH = 48, ;
NAME = &quot;Text1&quot;

PROCEDURE LOAD
SET SAFETY OFF
CREATE TABLE test FREE (CODE C(2), DESC C(15))
INSERT INTO test (CODE,DESC) VALUES (&quot;01&quot;,&quot;Apples&quot;)
INSERT INTO test (CODE,DESC) VALUES (&quot;02&quot;,&quot;Grapes&quot;)
INSERT INTO test (CODE,DESC) VALUES (&quot;03&quot;,&quot;Bananas&quot;)
INSERT INTO test (CODE,DESC) VALUES (&quot;04&quot;,&quot;Kiwi&quot;)
INSERT INTO test (CODE,DESC) VALUES (&quot;05&quot;,&quot;Oranges&quot;)
ENDPROC

PROCEDURE text1.INTERACTIVECHANGE

LOCATE FOR ALLTRIM(CODE) = ALLTRIM(THIS.VALUE)
THISFORM.combo1.SELECTED(RECNO())=.T.
THISFORM.combo1.REQUERY
ENDPROC

ENDDEFINE
*
*-- EndDefine: test
**************************************************

Al
 
Fishman13:

Insert this before the ENDDEFINE statement. It was omitted in the 2nd code.

PROCEDURE Destroy
CLEAR EVENTS
ENDPROC

Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top