Item not found in this collection

  • Thread starter Thread starter Connie via AccessMonster.com
  • Start date Start date
C

Connie via AccessMonster.com

I have just converted a replicated d.b. to a regular one by importing all
of the object except the tables, which I brought in using the 'make table
query' method suggested in other postings. I am now retesting the forms,
which I have inherited, and I have encountered the "Item not found in this
collection" error. I have read the other posts regarding this error, but I
am still lost about how to fix my own problem.

This error has only occurred since I converted the replicated d.b. to a
regular d.b.

The following snippet is the relevant portion called by a function as a
result of a user double clicking on a record in a list box on a search
form. I have been able to see that the correct variables have been passed
this far.

(BTW, I DO have the MS DAO 3.6 Object Library checked in the references)

***I would also like to mention that I was not the person who named the
tables with spaces in them - they are also inherited!

Public Sub FindEntity(intID As Integer, strName As String, frm As Form)
' being passed in might be: 10, "CompanyX", [Legal Entities]

Dim strSQL As String
Dim rstTemp As DAO.Recordset
Dim ctrlT As Control

Select Case frm.OpenArgs

Case "Legal Entities"
Forms("frmLegalEntity").Controls("EntityNo").SetFocus
Forms("frmLegalEntity").Controls("EntityNo").Text = intID
Forms("frmLegalEntity").Controls("EntityName").SetFocus
Forms("frmLegalEntity").Controls("EntityName").Text = strName

FillData intID, Forms("frmLegalEntity"), frm.OpenArgs
Forms("frmLegalEntity").Controls("Page1").SetFocus
End Select

DoCmd.Close acForm, "frmSearchEntity"
End Sub


Some of the data is filled in correctly but on the final page of a 5 page
form, it breaks and gives me this lovely error.

Any suggestions for this non-programmer would be greatly appreciated.
 
The collections referred to in this code are the Forms collection, and the
Controls collection, so the error indicates that one of the items referred
to in one of these two collections can not be found - either
'frmLegalEntity', 'EntityNo', 'EntityName', or 'Page1'.

When you see the error message, is there a 'Debug' button? If so, does
clicking that button highlight a specific line of code? If so, that should
give you a clue as to which of the items listed above can not be found.

Keep in mind that the Forms collection is a collection of *open* forms - if
the form 'frmLegalEntity' exists in the MDB, but is not open when this code
runs, that would cause the error you describe.
 

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

Back
Top