Solved

Run-Time Error 3012

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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