Solved

Run-Time Error 3012

Posted on 2002-05-20
4
2,267 Views
Last Modified: 2010-05-18
Hello:

When an Access database is opened, it gives "Run-Time Error 3012", "Object 'TodayRR' already exists" at:

d.CreateQueryDef "TodayRR", s

in:

Public Function MakeQuery(n As String)
    Dim d As Database
    Dim s As String
    On Error Resume Next  'skip if query doesn't exist
        If n = "RR" Then
            DoCmd.DeleteObject acQuery, "TodayRR"
        Else
            DoCmd.DeleteObject acQuery, "TodayDS"
        End If
    On Error GoTo 0
    Set d = CurrentDb
    If n = "RR" Then
        s = "SELECT FUNCTION, EMP, DATE_ENTERED, VOL, REG, OV, SMALL, LARGE, " & _
            "COUNTED, TRANS, LED FROM RetailReturns " & _
            "WHERE DATE_ENTERED=#" & SysDate & "#"
        d.CreateQueryDef "TodayRR", s
    Else
        s = "SELECT FUNCTION, EMP, DATE_ENTERED, VOL, REG, OV, TRANS, CHANGE_OVERS " & _
            "FROM DataServices " & _
            "WHERE DATE_ENTERED=#" & SysDate & "#"
        d.CreateQueryDef "TodayDS", s
    End If
End Function
=======================================

Thanks.


0
Comment
Question by:muhammasif
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Nosterdamus
ID: 7021683
Hi muhammasif,

It looks to me that query TodayRR is not deleted (for some reason).

I guess that you change:
   On Error Resume Next  'skip if query doesn't exist
       If n = "RR" Then
           DoCmd.DeleteObject acQuery, "TodayRR"
       Else
           DoCmd.DeleteObject acQuery, "TodayDS"
       End If

to:
   On Error Resume Next  'skip if query doesn't exist
       If n = "RR" Then
           DoCmd.DeleteObject acQuery, "TodayRR"
           DoCmd.OpenQuery "TodayRR"
       Else
           DoCmd.DeleteObject acQuery, "TodayDS"
       End If
 and see if TodayRR is opened. If it does, then the query is not deleted for some reason.

Please post stat, Thanks!

Nosterdamus
0
 

Author Comment

by:muhammasif
ID: 7021865
Changed the code. Same problem.

Tried to open TodayRR query manually. It said,

"Couldn't read definitions; no read definitions permission for table or query 'TodayRR'."

Can open all other tables and queries except this one.
0
 
LVL 2

Accepted Solution

by:
mjasic earned 100 total points
ID: 7022734
This seems to be a security problem. Go to Tools...Security...User and Group Permissions.

Find your user or group and click on. Then in Object Type select Query and above select TodayRR.

Click on all four check boxes and press Apply. It should give you access to this query.
0
 

Author Comment

by:muhammasif
ID: 7024255
Right on dot.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

937 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

7 Experts available now in Live!

Get 1:1 Help Now