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

Hello.... I designed a simpl

Status
Not open for further replies.

Hookstrat

Technical User
Jun 11, 2002
43
US
Hello....
I designed a simple phone directory and data access page for use over a local intranet. I am trying to put in custom filter/find buttons to search the directory by either company name or by last name. I was able to use a tutorial book and some Microsoft based help to insert the command buttons, clone the recordset, execute the find command and message box, and finally to write some custom error handling. However I have limited visual basic experience, so I was disappointed when I continued receiving "Error 3265: Item cannot be found in the collection corresponding to the requested name or ordinal". The message boxes, buttons, and error message boxes are displayed fine but no matter what is put in the input box, the same error is displayed. After some debugging to rule out as much as I could, I think the problem lies in either my attempt to clone the recordset, or my attempt to execute the find command. As you can imagine I was even more dissapointed to discover that the book I purchased only has one paragraph and zero examples dedicated to cloning a recordset.
Here is the code I am using:
Code:
 Dim rs
 Set rs = MSODSC.Datapages(0).Recordset.Clone 'how do I know what to put inside the ()?'
 On error resume next
 rs.find "Company = '" & CStr(InputBox("Please enter company to find","Find"))& "'"'
 If (err.number <> 0) Then
     Msgbox &quot;Error: &quot; & err.number & &quot; &quot; & err.description,vbOKOnly
 Exit Sub
 End If
 If (rs.bof) or (rs.eof) Then
     Msgbox &quot;No Product found&quot;,,&quot;Search Done&quot;
     Exit Sub
 End if
[\code]
I would greatly appreciate any help on this matter and thank anyone in advance for advice they can give.  I posted this about a week ago and got no response.                                                                                                                                                    Most appreciatively,
                                         Luke Hoekstra
 
I think you are missing your type assignment in the Dim statement. Here is a sample from one of my databases.

Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rstIwelcDate = db.openrecordset(&quot;Select Date from iwelcome&quot;)

(you probably won't need the 'DAO')

-chris John, I've been bad
and they're coming after me.
Done someone Wrong,
and I fear that it was me. -TMBG
 
Thanks for the reply Chris. I tried using your type assignment, and variations of, but I keep receiving scripting errors. Thanks anyways!
Luke Hoekstra
 
Make sure you are reffrencing 'Microsoft DAO 3.6 Object Library. And I messed up my declaration.
I copied the wrong SET statement.
Here is the correct one.

Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst= db.openrecordset(&quot;Select Date from iwelcome&quot;) John, I've been bad
and they're coming after me.
Done someone Wrong,
and I fear that it was me. -TMBG
 
Sorry Chris, this is my first time using data access objects!! How do I reference Microsoft DAO 3.0 Object Library????
 
On the VB editor, click on Tools, References, and select it from the list. It should be alphabetical under M.
Hope this helps,
Chris. John, I've been bad
and they're coming after me.
Done someone Wrong,
and I fear that it was me. -TMBG
 
I figured out the referencing problem, but I am still getting the same error!! &quot;Scripting error: Expected end of statement&quot;; it doesn't expect the AS statement after Dim db and after Dim rst Any Ideas???? Any help would be awesome. Luke Hoekstra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top