Find records within a data access page

N

NEC

I am using access 2000 and have a DAP that I created from a table. What I am
trying to do is essentially create a find command that will search all
records in the DAP based on user input. I have tried a few things but nothing
will work, this is one vbscript I have tried.

'-----------------------------------------------------------------------
'This routine searches all fields in the defaultrecordset for something
'entered by a user in a Search text box. It passes through each field
'the recordset until it finds a match.
'-----------------------------------------------------------------------
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
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


Please help if you can!! Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top