|
-
May 25th, 2001, 03:59 PM
#9
Combo Boxes...
Lets Imagine together that we create a table in the DataBase
Called(My Table)and it has Two Fields,The First one Is a primary Field called(The Code),and the second Field called(Name)..
-------------------------------------
The Code Name
-------------------------------------
1 Ahmed
2 OLA
3 Kholoud
4 Tom
5 Adam
--------------------------------------
In the Form_Load()Event ..Lets Fill Combo1 with the above Names
Private Sub Form_Load()
Dim Rs as ADODB.Recordset
set Rs=new Recordset
Rs.Open "MyTable",Con-------->>Con is refer to Connection Object.
Rs.MoveFirst
Do Until Rs.Eof
Combo1.addItem Rs.fields("Name").value---->>Fill the Combo1 with the ----Values of this Field.
Combo1.ItemData(Combo1.NewIndex)=Rs.Fields("The Code").value
Rs.moveNext
Loop
End Sub
*******
In the Combo1_Click()Event
Private Sub Combo1_Click() event
Dim Val
Val=Combo1.ItemData(Combo1.ListIndex).value
End Sub
-->>Now this Val Refer to the Value of((The Code))Field
Hope I could Make it More Clear now..
Have Good Luck again..Bye
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|