niño_morata 0 Newbie Poster

hi.! Im niño morata. Can you plz solve my problem. I have a assignment datagrid search..
when I click search command botton to my program...there is problem, but when I try to click a search command botton again the msgbox say that "no record found"

[ code of search command botton ]

1. Dim N As String
2. N = Inputbox (Combo1 & " search")
3. adodc1.Recordset.Find Combo1.List (Combo1.ListIndex " = " ' & N & ' " ' ")
4. if adodc1.Recordset.EOF Then
5. msgbox "no record found"
6. end if

can you plz add some code to my program....
thks :D

Dani AI

Generated

For @ninomorata — the symptom "search works once, then reports 'no record found' on further tries" is usually a pointer issue, not a grid bug. With classic ADO the Find method starts at the record currently selected; if the pointer is left at or past the matched row (or at EOF) the next Find will not search earlier rows. A safe first step is to reset the record pointer before each search and to guard against an empty recordset.

Two practical fixes:

  • Reset the recordset position before searching (check BOF/EOF first, then MoveFirst), then run the search and test EOF to detect no match. Also avoid calling MoveFirst on an empty recordset.
  • Prefer re-querying or filtering the data and rebinding the grid instead of using Find. Re-running a SELECT with a WHERE clause (or using a DataView.RowFilter / DataTable.Select in .NET) is more predictable and works cleanly with databound controls.

Example pattern for ASP.NET/VB.NET: use a parameterized SELECT, fill a DataTable, set it as the DataSource and call DataBind. This avoids pointer-state bugs and is safer for user input.

Troubleshooting checklist: verify the correct column name and data type, escape or parameterize user text, handle empty recordsets, and call the grid refresh/bind method after replacing the data source. For classic ADO, remember RecordCount may be unreliable for certain cursor types, so rely on BOF/EOF checks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.