Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / May 2005



Tip: Looking for answers? Try searching our database.

Using the datacombo control with the ado data control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bookreader - 28 May 2005 21:04 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
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.