Query can't find object

Posted on 2012-09-14
Last Modified: 2012-09-19
Hi Everyone,

(This is Access 2007, not sure if the question is posted to the right spot)

I have a 2 part question.  What I am trying to do is use the entry from a combo box as the criteria for a field in a select query.  If a name is selected, use that name, if nothing is selected search everything.  The bound column for the combo box is the person's ID number, so although the selection is text the search uses a numeric field.  After lots of searching yesterday, I was able to finally come up with the below as an expression, with the criteria set as "true".  "CatchSummary" is the table I am searching, "CatchByCode" is the ID number for the person. "NameForSearchCombo" is the combo box on teh master form which returns the ID number of the person selected.   If nothing is selected, search for all (ID #s >0); if something is selected search for just that one.    This was working yesterday, but when I opened the DB today, the query can't find the "NameForSearchCombo" object and presents a parameter query dialog box.  After some fiddling around, using just the name instead of all the iif language, I was able to get it working again.  I then closed and reopened the DB and the object again was not found.

So my questions are: 1) Is there a better way to do this? and 2) Why does the DB "lose" this object one it is closed.

Expression in the Field row:


Question by:Andy419
    LVL 77

    Expert Comment

    The method I use is to modify the Where clause in SQL view......

    where ([CatchSummary].[CatchByCode]=[Forms]![Masterform]![NameForSearchCombo]) or [Forms]![Masterform]![NameForSearchCombo] is null

    Author Comment

    Thanks!  That didn't seem to work either, but maybe this is a larger issue:  I tried to do a very basic select query using a date field as the criteria.  I even used the builder to make sure the object was being seen and was pasted in correctly.  Even with this the query couldn't see the object and put up a parameter query dialog box.    Does anyone know why the query is not recognizing any of the objects on the master form?  I've done this probably 1,000 times without any issues -- I don't get why this time it doesn't work.

    Author Comment

    One more update -- it seems like the objects are not being loaded to memory(?) when the DB is opened.  When I first open the DB and try to run the query I get a dialog box since the object isn't being recognized.  If I load use the Object Browser or just use <F-11>, once I exit that screen, the query works just fine.  Is there a way to make sure that all objects are loaded when the DB is opened?

    Accepted Solution


    I started this DB by copying an existing DB I am using.  Looking at the VBA screen I noticed that the project for this one still had the name of the older one.  Once I renamed the project to the current name, I did not have anymore issues with the objects not being found.
    (for now anyway)

    Author Closing Comment

    Seems to be working now

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now