• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

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
0
spacetraveller
Asked:
spacetraveller
  • 3
  • 2
1 Solution
 
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
 
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
 
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

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now