Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run-Time Error 3012

Posted on 2002-05-20
4
Medium Priority
?
2,389 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 400 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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