I have an ado data control that uses a select statement to get all the
customer names from a database. Then I use the datacombo control to
display the customer names.
That all works fine.
Then the user selects a customer name.
Then I get the datacombo.SelectedItem field to give me a bookmark to
the row in the recordset.
For example, MsgBox dcCustomer.SelectedItem shows the bookmark number.
Now I am stuck. I know that I am missing something really simple.
How do I get the actual customer name from the recordset? Let's say
that the field is called CustName.
Thank you in advance.
Jorge Jimenez - 29 May 2005 19:24 GMT
If you use the datacombo to show the names then
dcCustomer.text should have the customer name
(no need to read it from the recordset)
To get any other field:
rs.Bookmark = dcCustomer.SelectedItem
then, for example,
CustomerPhone = rs.Fields("CustPhone").value

Signature
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
>I have an ado data control that uses a select statement to get all the
> customer names from a database. Then I use the datacombo control to
[quoted text clipped - 15 lines]
>
> Thank you in advance.
Bookreader - 29 May 2005 22:04 GMT
>If you use the datacombo to show the names then
>dcCustomer.text should have the customer name
[quoted text clipped - 5 lines]
>then, for example,
> CustomerPhone = rs.Fields("CustPhone").value
That is exactly what I needed.
Thank you.
Mark J. McGinty - 29 May 2005 20:50 GMT
>I have an ado data control that uses a select statement to get all the
> customer names from a database. Then I use the datacombo control to
[quoted text clipped - 13 lines]
> How do I get the actual customer name from the recordset? Let's say
> that the field is called CustName.
A bookmark is only significant to the recordset from which it was taken (or
a clone of that recordset.) Even if you open two recordsets using the exact
same SQL statement, bookmarks from one may not work with the other.
So if you're binding the datacombo to an ADODC control, you can access its
underlying recordset via the ADODC.Recordset property, and you can position
that recordset by assigning its Bookmark property. (Usually best to use a
clone, to avoid side-effects of changing the position of a recordset bound
to controls.)
Dim rs As ADODB.Recordset
Set rs = adodc1.Recordset.Clone()
rs.Bookmark = dcCustomer.SelectedItem
Don't forget to close the clone when you're done with it, this will not
close the recordset from which the clone was taken.
-Mark
> Thank you in advance.