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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box

Status
Not open for further replies.

ysommer

Programmer
Feb 26, 2001
45
Hi!
How can I make an index combo box, I mean a combo box which I write the first letter and than only words that begin with that letter appear, and than I can choose...

Tnx In advance...
 
make a query that contains three fields
1. The field you want to display (ex: Nomen)
2. An Expression Field that Tests the 1st Character of the value Entered into the ComboBox (i.e. cboNomen on Form1)
3. An Expression Field that Tests to see if cboNomen is Null, and if so returns all records


So the SQL for the above from a table with the name tblWSFRecords would be:

SELECT tblWSFRecords.Nomen, Left([nomen],1) AS exp, [Forms]![form1]![cboNomen] AS Expr1
FROM tblWSFRecords
WHERE (((Left([nomen],1))=[Forms]![form1].[cboNomen])) OR ((([Forms]![form1]![cboNomen]) Is Null))
ORDER BY tblWSFRecords.Nomen;


Then in the AfterUpdate event for the ComboBox, test the length of the value in the ComboBox, and if it is 1, then Requery the ComboBox.

Private Sub cboNomen_AfterUpdate()
If Len(cboNomen) = 1 Then
cboNomen.Requery
End If
End Sub

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top