Solved

Run-Time Error 3012

Posted on 2002-05-20
4
2,238 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Right on dot.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

763 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

6 Experts available now in Live!

Get 1:1 Help Now