Solved

Run-Time Error 3012

Posted on 2002-05-20
4
2,283 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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

776 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