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

Finding a Record Existing in a Form

Status
Not open for further replies.

scking

Programmer
Jan 8, 2001
1,263
US
I'm attemping a simple task which is causing me problems. I want to be able to move to a record which meets certain criteria (not filter). The criteria would be something like "PN=XYZ". The BindingSource.Find seems to find an index number but the BindingSource.Position = foundIndex isn't working in the form and I suspect it only works with IList controls. Could someone please point the way.

---------------------
scking@arinc.com
---------------------
 
need more detail. Code helps, even if its pseudo code.

-The answer to your problem may not be the answer to your question.
 
I've discovered the solution. Using the BindingSource.Find("PN", "167-84C") returned the index if it is found. Then simply using the CurrencyManager to reposition to the found index works marvelously. But it's not terribly well documented.

From any open form example:
frm.FindItem("PN", "167-84C") would reposition the form to the part number.

Friend Sub FindItem(ByVal SearchItemName As String, ByVal SearchKey As String)

' Searches the form DataSource for the LRU PN
' If an index is found it was successful
' and uses the CurrencyManager to move to the index

Dim itemIndex As Integer
If Me.TblLruBindingSource.SupportsSearching <> True Then
MessageBox.Show("Cannot search.")
Else
itemIndex = Me.TblLruBindingSource.Find(SearchItemName, SearchKey)
If itemIndex > -1 Then
Me.TblLruBindingSource.CurrencyManager.Position = itemIndex
Else
MessageBox.Show(SearchItemName & " was not found.")
End If
End If

End Sub

---------------------
scking@arinc.com
---------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top