You might do something like:
... where strTarget is the field to search. If practical just hardcode it in the search expression. This will move the "current row" in the datagrid however.Code:Private Sub Command1_Click() With Adodc1.Recordset .Find "[" & strTarget & "] = '" & Text1.Text & "'", , _ adSearchForward, adBookmarkFirst If .EOF Then MsgBox "Not found" Else MsgBox "Found at record " & CStr(.AbsolutePosition) End If End With End Sub
Alternatively you might use:
Searching all fields would require you to loop through the Recordset for each field of the desired type until you hit a match.Code:Private Sub Command2_Click() Dim rsCopy As ADODB.Recordset Set rsCopy = Adodc1.Recordset.Clone(adLockReadOnly) With rsCopy .Find "[" & strTarget & "] = '" & Text1.Text & "'", , _ adSearchForward, adBookmarkFirst If .EOF Then MsgBox "Not found" Else MsgBox "Found at record " & CStr(.AbsolutePosition) End If .Close End With End Sub




Reply With Quote