project runtime errors 3265 and 2162

Posted on 2006-04-13
Last Modified: 2008-02-01
I named a database as Report (stupid thing that I did in the beginning!!!!!) and for unobvious reasons I was getting errors while trying to use the Report in the VBA. So I made a brand new project in MSaccess and copied all the modules and class files to this new project. I also copied the forms. Now the statements that worked fine in the old project do not work in this project.

I am using the following statements

First I use:

"Dim strSQL As String
strSQL = "SELECT  tblFATS.* FROM tblFATS WHERE ID1 >= 50"
CurrentDb.QueryDefs("MYTempQuery").sql = strSQL"

and I get the following error

Runtime error 3265
Item not found in this collection

I commented that statement and I proceed with the execution of the following statement

DoCmd.FindRecord strsearch, acAnywhere, False, acSearchAll, , acAll, False

I am getting the following error:

Runtime Error 2162
A macro set to one of the current fields properties failed beacuse of an error in a FindRecord action argument.

Please help

Question by:spacetraveller
    LVL 14

    Expert Comment

    Does MyTempQuery already exist?  If not, you'll need to create it.

    Replace this line

    CurrentDb.QueryDefs("MYTempQuery").sql = strSQL

    with this:

    CurrentDb.CreateQueryDef("MyTempQuery", strSQL)

    When you're done, you can also delete it by calling


    Author Comment

    Hi John, I am getting
     compile error
     Expected: =

    LVL 14

    Accepted Solution

    OK, let's try something else.  Create a new query.  Leave it blank and save it as "MYTempQuery"

    Then, try running your original code.  (Don't use my CreateQueryDef line.)

    Author Comment

    It worked!!! Thanks. But, I want to create and delete Queries at run time. Is there a solution for that.

    Thanks A lot.
    LVL 14

    Expert Comment

    Sorry I was never able to get back to you spacetraveller; I've been under the weather lately.  Feel free to open a new question to give someone else a chance to explain creating and deleting queries at run time.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now