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

filling a combo box

Status
Not open for further replies.

technohead

Technical User
Jan 12, 2002
64
US
Hi,

i have a form with about 15 tabs on it. on the click event of each tab a combo box is filled. this works perfectly, however when i load the form the first page has nothing in the combo box. i have to click onto another tab and then click back to the first one so that the combo box is filled.

heres the code i used below.
is there any way that this can be done without having to click to another page first.


Private Sub SSTab1_Click(PreviousTab As Integer)


If SSTab1.Tab = 0 Then
intfloortype = 1
ElseIf SSTab1.Tab = 1 Then
intfloortype = 2
ElseIf SSTab1.Tab = 2 Then
intfloortype = 3
ElseIf SSTab1.Tab = 3 Then
intfloortype = 4
ElseIf SSTab1.Tab = 4 Then
intfloortype = 5
ElseIf SSTab1.Tab = 5 Then
intfloortype = 6
ElseIf SSTab1.Tab = 6 Then
intfloortype = 7
ElseIf SSTab1.Tab = 7 Then
intfloortype = 8
ElseIf SSTab1.Tab = 8 Then
intfloortype = 9
ElseIf SSTab1.Tab = 9 Then
intfloortype = 10
ElseIf SSTab1.Tab = 10 Then
intfloortype = 11
ElseIf SSTab1.Tab = 11 Then
intfloortype = 12
ElseIf SSTab1.Tab = 12 Then
intfloortype = 13
End If

Call result(intfloortype, cbowoodtype(SSTab1.Tab))



Public Sub result(TypeNum As Integer, combo As Control)
combo.Clear
Dim adoconnection As ADODB.Connection
Set adoconnection = New ADODB.Connection

adoconnection.Open ("Provider=Microsoft.jet.oledb.4.0;" & "Data Source = C:\Final_Year_Project.mdb")

Set rs = New ADODB.Recordset
rs.Open "select WoodTypeName, WoodType_No from WoodType where FloorType_No=" & TypeNum, adoconnection


While Not rs.EOF
combo.AddItem rs("WoodTypeName")

rs.MoveNext
Wend


End Sub
 
You can add this code in the event "load" of your form :

For intfloortype = 1 To 13
Call result(intfloortype, cbowoodtype(intfloortype-1))
Next

You'll get the initialisation of all combo's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top