Ms Access Runtime Error 3012
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Run-time error 3167 and Run-time error 3012 up vote 0 down vote favorite I have a question regarding the code below which creates a new query based on combobox selections or a textbox entry on an Access form. Sometimes when I run the query it works fine and other times I get one of two errors. I think it has to do with either the code that creates the "sqlquery" query itself the deletion of the "NewQuery" after its created or a combination of both. Any assistance you can provide would be greatly appreciated. I have been trying a variety of different solutions for hours, but I am coming up short. The first error I receive is Run-time error 3167 Record is deleted on the line DoCmd.OpenQuery "NewQuery". The next error I receive on other occasions is Run-time error 3012 Object "NewQuery" already exists on the line Set qdf = CurrentDb.CreateQueryDef("NewQuery",sqlquery). Thank you. On Error Resume Next CurrentDb.QueryDefs.Delete "NewQuery" If Text24 <> "" Then sqlquery = "SELECT * FROM TABLE WHERE TABLE.WorkerID = [Forms]![UserForm]![Text24];" Else ComboBox_condition = "" If ComboBox0 <> "" Then ComboBox_condition = ComboBox_condition + " TABLE.PayGroupRegionCode = '" & ComboBox0 & "'" End If If ComboBox0 <> "" And ComboBox4 <> "" Then ComboBox_condition = ComboBox_condition + " TABLE.PayGroupCountryDesc = '" & ComboBox4 & "'" ElseIf ComboBox4 <> "" Then ComboBox_condition = ComboBox_cond
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Run-Time Error 3012 Want to Advertise Here? Solved Run-Time Error 3012 Posted on 2002-05-20 MS Access 1 Verified Solution 4 Comments 2,220 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 http://stackoverflow.com/questions/33627835/run-time-error-3167-and-run-time-error-3012 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 & "#" https://www.experts-exchange.com/questions/20302564/Run-Time-Error-3012.html 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 Question by:muhammasif Facebook Twitter LinkedIn Google LVL 2 Best Solution bymjasic 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 Go to Solution 4 Comments LVL 7 Overall: Level 7 MS Access 7 Message Expert Comment by:Nosterdamus2002-05-20 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 Message Author Comment by:muhammasif2002-05-20 Changed
Custom Search UtterAccess Forums>Microsoft® Access>Access Errors + Error Handling Runtime Error 3012 - Table Already Exists Forum HomeSearchHelpUA Messages|-- UtterAccess.com NewsAccess Knowledge Center|-- Access Code Archive|-- Access Knowledgebase http://www.utteraccess.com/forum/Runtime-Error-3012-Tabl-t1964893.html / FAQ|-- Access TutorialsMicrosoft® Access|-- Local Access User Groups (AUGs)|-- Interface Design|-- Access Q and A|-- Access Tables + Relationships|-- Access Queries|-- Access Forms|-- Access Reports|-- Access Macros|-- Access Modules|-- Access Date + Time|-- Access Errors + Error Handling|-- Access Built-in Functions|-- Access Searching + Data Mining|-- Access Records|-- Access Security|-- Access Automation|-- Access Database Container|-- Tool bars, Menu bars + ms access Ribbon|-- Access Services (Web Databases)|-- Access Data Access Pages (Deprecated)|-- Access Data Projects - ADP|-- Access Runtime, Packaging & DeploymentAnd More...|-- Microsoft SQL Server|-- SQL Server Reporting Services|-- Microsoft SharePoint|-- Microsoft Internet Explorer|-- Visual Basic 6 and Earlier|-- Visual Basic 2003 and Later|-- ASP and VBScript|-- Web Development|-- PHP, Perl, MySQL and Postgres|-- Other Database Engines|-- BI Tools and Applications|-- JAVA ms access runtime and C#|-- GraphicsMicrosoft® Office|-- Microsoft Excel|-- Microsoft Excel FAQs|-- Microsoft Word|-- Microsoft Outlook|-- Microsoft PowerPoint|-- Microsoft FrontPage/Exp. Web|-- Other Microsoft ProductsPC|-- Network Issues|-- Q & A - Hardware|-- Q & A - Software|-- Q & A - Other PC|-- Virus + Security DiscussionUtterAccess Odds and Ends|-- General Chat|-- Q & A - UtterAccess.com Forums|-- Q & A - Access Wiki Options themapperView Member Profile Apr 5 2011, 11:55 AM Post#1Posts: 19Joined: 8-March 11Hi everyone,I have a database that is accessed by several users via the network. When they open it they see a form where they choose some parameters and click a command button. The result is a query runs to make a temporary table that is then exported to an Excel spreadsheet. The user is given the option of where to save the table and once chosen the query runs, the table is exported and the database closes. What is happening on occasion...and I think it's because more than one user are using the database at the same time, is a user gets a runtime error box sayi