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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding an item in a datacombo box and selecting it

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
This is a Datacombo box and is connected to an ADODC control
I see the MatchEntry and Match List properties
I want to see if an item from my Datagrid matches an item in the combo box and select it
here is waht I have so far
Me.cboEmp1.MatchEntry = AddNewAudit.DataGrid1.Columns(5).Text

TIA

DougP, MCP, A+
 
hi

u just need to move the recordset that u assigned to the rowsource to the record u wnat
use rs.filter or rs!move()

ex
dim rs as recordset
rs.open(select * from order")

set cmborder.rowsource=rs
cmborder.listfield="OrderNo"



' to do what u want u can do this
rs.move(0,20)
this will select the 20th record


 
The move command actually moves the pointer to the specified record, the filter command restricts the view to records with a particular criterion set. If you use the latter to restrict the view to only one record, that will be the current record of course.

Bob
 
Ok I have Part# 12091
in a list of 4200 some parts
how do I select that part
rs.Move 12091 ????

DougP, MCP, A+
 
Hi DougP
I'll take a stab at it but I have a couple of questions. Are both datagrid and datacombo, pointed to the same datasource? If so, then wouldn't the combo box become simply like a text box staying in sync with the current record selected? For example the NWind database, if you create an ADODC pointed to the Orders Table, and a DataCombo pointed to field CustomerID of same ADODC, doesn't the CustomerID stay in sync with the current record? Or is the DataCombo pointed to a different data source like the customers table? If so the Find method should work for you.

Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "CustomerID = " & DataCombo1.Text

Hope this helps you out.
Later
 
Well there are 2 ways to connect a DataCombo box to an ADODC control.
1st way is the same as a regular text box in which only one item shows up and you have to move the ADODC control so see the data. (not very effective as a combo box) This method
uses the DataSource property to find your ADODC and then the DataField property to set the Column or field.
The second way shows all the items of the recordset as a drop down, uses the RowSource property and then the ListField property. I am using the later.
I found that by just using DataControl.BoundText = “12091”
or
DataControl.BoundText =AddNewAudit.DataGrid1.Columns(5).Text
It worked and just happened to be on that particular record in the recordset when I clicked the datacombo box as well. So it is in fact finding it in the list.

If I move the underlying record set as mentioned nothing shows in the DataCombo box even though I also had a bound text box as a test to see if the ADODC control was in fact moving. It was and the data in that text box moved back and forth when I used the navigation buttons in the ADODC control and they did not move in the DataCombo box.


DougP, MCP, A+
 
>The second way...
I thought when using the second way, for correct usage, you create 2 ADODC's. With the NWind example above, you would create ADODC1 for the Orders table, ADODC2 for the Customer table. Then with DataCombo1 DataSource=ADODC1, DataField=CustomerID, RowSource=ADODC2, ListField=CompanyName, BoundColumn=CustomerID. After all is set correctly you should see in the datacontrol the user friendly CompanyName instead of the Customer ID and selecting a different CompanyName changes the CustomerID in the Orders table.

If your still following me, add another DataCombo and set RowSource = ADODC2, DataSource=ADODC2, ListField=CustomerID, BoundColumn=CustomerID and add this procedure.

Private Sub DataCombo2_Change()
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "CustomerID = " & "'" & DataCombo2.Text & "'"
End Sub

You should now see your desired results.

Implementing another lookup mechanism requires another ADODC, thus taking up more connection resources from the server, and not sharing the same transaction space. I think this is one of the reasons, alot of programmers don't use Data Controls. If you think I'm headed in the right direction, I can show you how to somewhat overcome the resource problem.

Later
 
I guess the confusion comes from the
AddNewAudit.DataGrid1.Columns(5).Text
which is on another form alltogether and is where I am getting a particular value that I want to find in a DataCombo box on the second form.
So No both DataGrid and DataCombo are not looking at the same ADODC nor are they even on the same form
Sorry

Which is why I put in the
"Ok I have Part# 12091
in a list of 4200 some parts
how do I select it?"

Anyway 'Nough said I fixed it.


DougP, MCP, A+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top