Hi... Newbee question.
After a long search with a lot of abused language.. hèhè.. I finaly got the values from a database in a Combo. After much, much, much more filthy language I hope someone can help me out with this:
I created an AccesDatabase: (Example)
Row1 (Fieldname: Postcode) = 1,2,3,4 etc
Row2 (Fieldname: Plaats) = A,B,C,D etc
If I choose "2" in Combo1 I want Text1.Text to be "B".
Someone know how to do that? Or perhaps a link where I can find how to do that? (want to learn)
The code I use to fill the items from the database into the Combo:
---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
After a long search with a lot of abused language.. hèhè.. I finaly got the values from a database in a Combo. After much, much, much more filthy language I hope someone can help me out with this:
I created an AccesDatabase: (Example)
Row1 (Fieldname: Postcode) = 1,2,3,4 etc
Row2 (Fieldname: Plaats) = A,B,C,D etc
If I choose "2" in Combo1 I want Text1.Text to be "B".
Someone know how to do that? Or perhaps a link where I can find how to do that? (want to learn)
The code I use to fill the items from the database into the Combo:
Code:
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Code:
Private Sub Form_Load()
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = _
"Data Source = C:\SEARCH.MDB;" & "Persist Security Info = False"
.Open
End With
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.CursorLocation = adUseServer
.CursorType = adOpenDynamic
.Source = "Blad1"
.Open
End With
If Not rs.EOF And Not rs.BOF Then
rs.MoveFirst
Do While Not rs.EOF
Combo1.AddItem rs!postcode
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King