project runtime errors 3265 and 2162

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

Thanks,
st
spacetravellerAsked:
Who is Participating?
 
JohnK813Commented:
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.)
0
 
JohnK813Commented:
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

CurrentDb.QueryDefs("MYTempQuery").Delete
0
 
spacetravellerAuthor Commented:
Hi John, I am getting
 compile error
 Expected: =

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

Thanks A lot.
st
0
 
JohnK813Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.