• Welcome to Valhalla Legends Archive.
 

[VB6] Binding Controls with ADO

Started by Sorc.Polgara, July 06, 2004, 06:37 PM

Previous topic - Next topic

Sorc.Polgara

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

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

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.

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

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

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

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

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


txtOne.DataField = "FieldOne"
Set txtOne.DataSource = rst

txtTwo.DataField = "FieldTwo"
Set txtTwo.DataSource = rst


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.