Valhalla Legends Forums Archive | Visual Basic Programming | [VB6] Binding Controls with ADO

AuthorMessageTime
bethra
Salve

I want to bind a few Textbox Controls with ADO to a Table in a .mdb, which I made using MS Access. Each txtbox control would be binded to different Field in this Table...

I'll create a scenario to help describe this...

One a Form there are 3 Textbox Controls would be named:
[quote]
txtOne, txtTwo, and txtThree
[/quote]

A table in a Microsoft Database (.mdb) would have 3 fields all with text value data:
[quote]
FieldOne, FieldTwo, Field Three
[/quote]

What I want to do is have,
[quote]
txtOne binded to the data in FieldOne.
txtTwo binded to the data in FieldTwo.
txtThree binded to the data in FieldThree.
[/quote]

Each of these 3 Fields data, records, would be somehow errrmm well like this
[quote]
FieldOne----FieldTwo----FieldThree
data1--------data1-------data1
data2--------data2-------data2
data3--------data3-------data3
[/quote]

The relationship between the 3, FieldOne, FieldTwo, FieldThree would be similar, if not the same, as a .ini files thingy
[quote]
[Section]
key1=
key2=
[/quote]

Now, for instance...

I have a listbox on the Form showing a list of the values in FieldOne.
When I click on an index in the listbox... with the text "data1" the txtboxes would automatically change their text to the data in their respective fields:
[quote]
txtOne = data1 of FieldOne
txtTwo = data1 of FieldTwo
txtThree = data1 of FieldThree
[/quote]

--------------------------------

OK I'm not asking for how to do all of this, I need help on the part when I click on the index in the listbox the data in the fields are displayed in its binded textbox.

I'm not quite coming into this clueless. I have a VB book which taught me how to make ADODB objects, create connections to recordsets and a very basic information some methods and properties.

It also gave me alittle info on binding controls with ADO, but it really only gets me this far

[code]
txtOne.DataField = "FieldOne"
Set txtOne.DataSource = rst

txtTwo.DataField = "FieldTwo"
Set txtTwo.DataSource = rst
[/code]

rst is the Recordset...

I've spent perhaps a few hours experimenting and trying to do what I've said above. Its not working for me. I needs some help please, any helpful code is greatly welcomed.

Thanks for your time.
July 6, 2004, 11:37 PM

Search