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!

Text1 = Member Items Combo1

Status
Not open for further replies.

jajinder

Technical User
Mar 11, 2004
88
NL
Hi... newbee question...

Created a Acces-Database and a connection. I got the values of a row in a Combo. Furthermore 2 TextBoxes.
If I select a value from the Combo I want to have the value in a Text of the other row (the row next to) I hope u understand what I am trying te say.

Code for the connection I created:

Option Explicit

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

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
Combo2.AddItem rs!Plaats
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
 
You mean the field next to????

If so just use a Select Statment to select * FROM Table WHERE Field = Combobox..Then fill in the textbox with Text1.Text = rs.Fields("FieldName")

I am not sure if thats what you mean or not.

 
And, use the code that dvannoy has provided in the Combos' Click event.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top