data access page runtime error

  • Thread starter Jessica via AccessMonster.com
  • Start date
J

Jessica via AccessMonster.com

I've been trying to use this
http://support.microsoft.com/default.aspx?scid=kb;en-us;271728 to create a
search form. Everytime I run the script on my data access page. I get a
runtime error on line 513, which is rs.Find fld.name & " = '" & txtSearch.
value & "'", 0, 1, 1

The code behind the command button is:
'-----------------------------------------------------------------------
'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
 

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