Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am making project in vb6.0 using ms-access database, I am running query to display records in msflexgrid.
rs1.Open "select cname, desg, division,dept,ministry From data_detail where country='" & cmbcontry.Text & "' GROUP BY cname, desg, division,dept,ministry HAVING Count(*)>1 ", con, adOpenStatic, adLockOptimistic, adOpenKeyset

But it is showing following error
Item cannot be found in the collection corresponding to the requested name or ordinal
I am using combobox to select country and display its corresponding records in grid.
I use the following code
VB
If rs1.RecordCount > 0 Then
      rs1.MoveFirst
      While (rs1.EOF = False)
      trec = trec + 1
      rs1.MoveNext
      Wend
      End If
       trec = 6
        Mf1.Rows = rs1.RecordCount + 1
        Mf1.Cols = 6
        Mf1.Row = 0
        Mf1.Col = 1
        Mf1.Text = "CName"
        Mf1.Row = 0
        Mf1.Col = 2
        Mf1.Text = "Designation"
        Mf1.Row = 0
        Mf1.Col = 3
        Mf1.Text = "Division"
        Mf1.Row = 0
        Mf1.Col = 4
        Mf1.Text = "Department"
        Mf1.Row = 0
        Mf1.Col = 5
        Mf1.Text = "Ministry"
          For i = 0 To rs1.RecordCount - 1
            rs1.MoveFirst
            rs1.Move i
            Mf1.Row = i + 1
            'For rl = 1 To rs1.RecordCount
             '   For dup = 2 To rs1.RecordCount
            'If (r1! = dup) Then
            
            Mf1.Col = 1
            Mf1.Text = rs1.Fields(9)//where i am getting this error
            Mf1.Col = 2
            Mf1.Text = rs1.Fields(10)
            Mf1.Col = 3
            Mf1.Text = rs1.Fields(11)
            Mf1.Col = 4
            Mf1.Text = rs1.Fields(12)
            Mf1.Col = 5
            Mf1.Text = rs1.Fields(13)
            rs1.MoveNext
         Next
        For i = 1 To Mf1.Rows
           For j = 0 To Mf1.Cols - 1
                Mf1.Row = i - 1
                Mf1.Col = j
            Next
        Next

Act my aim is to find same records and display them in grid.
Please tel me where I am wrong.
Thanks in advance....
Posted
Updated 23-Oct-11 22:48pm
v3

1 solution

Check this
Item cannot be found in the collection corresponding to the requested name or ordinal
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
This like the error above is a recordset error. You have tried requesting a field from the recordset that does not exist.

Check when you are reading in the field from the recordset into a variable or to display in a web page that you have spelt the field name correctly and that the field exists in the database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900