VB6: Dear sir, For the following code I am getting "Run-time error'3265': Item cannot be found in the collection corresponding to the request name or ordinal."
However, I already connected Adodc1 to my database from where I want the data.
Actually, what Im trying to do is, just to get record list from particular field of Table from MSAccess Database in my ComboBox, so I could retrieve the record. I was using DBCombo1 and used "ListField" in the properties and connected it to Adodc1 but I could only succeed in getting records in the list but if I select any record suppose "CustomerID" it is not getting the rest of record like "CustomerName" and "Address" etc. in TextBoxes Im using in my VB Form.
I tried many times but could not succeed. Please if anybody can help me in it. I will be so grateful because I have to finalize my company database with in few days.
Thanks in advance.
Have a Good Day...!!!.
If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "ID='" & DBCombo1.Text & "'"
If Adodc1.Recordset.EOF = False Then
If Adodc1.Recordset!FirstName <> "" Or IsNull(Adodc1.Recordset!FirstName) = False Then
Text1.Text = Adodc1.Recordset!FirstName
Else
Text1.Text = ""
End If
If Adodc1.Recordset!Address <> "" Or IsNull(Adodc1.Recordset!Address) = False Then
Text2.Text = Adodc1.Recordset!Address
Else
Text2.Text = ""
End If
End If
End If
End Sub
Hi Scorpian,
You need not any ADODB object, it is very simple follow these steps.
1. Open your Access Form in Design mode
2. Select the combo box and right click and select its properties
3. You will get all properties of combo box and type the following SQL at "Row Source" Property, thats it.
select fieldname from tablename.
Example: select empname from emp;
The above query will display all employee names from emp table in combo box when you open your FORM.
Feel free to ask me any Access questions.
Subbu.
Sorry, I miss one more property,
Select RowSource Type property as Table/Query before giving SQL query to Row Source.
Hope you will understand my answer.
Discuss This Question: 2  Replies