Expand|Select|Wrap|Line Numbers
- 'code from MSDN for a simple search function.
- 'http://support.microsoft.com/kb/271728
- dim i 'Counter variable
- dim rs 'ADO recordset object
- dim fld 'ADO field object
- dim FieldCount 'Number of fields in the recordset
- FieldCount = MSODSC.DefaultRecordset.Fields.Count
- 'This will return the default recordset on the page
- 'in this case, the Customers table.
- set rs = MSODSC.DefaultRecordset
- for i = 0 to FieldCount - 1
- 'get a field object
- set fld = rs.Fields(i)
- '0 = Skip no records
- '1 = Search forward
- '1 = Start with the first record
- 'the next line is where the debugger stops on the error.
- rs.Find fld.name & " = '" & txtSearch.value & "'", 0, 1, 1
- 'Check for EOF. If at EOF but have not exhausted
- 'all the fields, then reset to the first position in the
- 'recordset. Otherwise, if a match was found, exit the loop.
- if rs.EOF then
- rs.MoveFirst
- else
- exit for
- end if
- next
- 'Clean up.
- set fld = nothing
- set rs = nothing