Access Runtime Error 2501 Openform
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings access runtime error 2501 the openform action was cancelled and policies of this site About Us Learn more about Stack Overflow
Run Time Error 2501 The Openform Action Was Cancelled
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Ms Access Runtime Error 2501
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Microsoft Access Runtime Error 2501
only takes a minute: Sign up How to prevent “OpenForm action was cancelled” in legacy Access Code up vote 2 down vote favorite 1 I recently took over a VERY old Access database. This database has a TON of macros written that the users utilize to help them navigate and enter data. Thus, ditching the code is not step #1 despite access 2010 runtime error 2501 the fact that these macros were written in Access 97.... I've managed to get most of the code to work by removing deprecated function calls with new ones, but there are a couple of forms that still do not work correctly. If I can figure out how to resolve one I'm sure I can resolve the others. The main macro has a menu with several buttons. Whenever I click one button I get a "The OpenForm action was cancelled" error. The code for this button is as follows: Option Compare Database 'Use database order for string comparisons Private Sub Form_Open(Cancel As Integer) If IsLoaded("ServiceCircuit") Then Me![PropBtn].Visible = True Else Me![PropBtn].Visible = False End If End Sub Private Sub Form_Unload(Cancel As Integer) If IsLoaded("ServiceCircuit") Then Forms![ServiceCircuit].Visible = True Forms![ServiceCircuit]![CircuitPrefix].Requery Forms![ServiceCircuit]![CircuitPrefix] = Forms![Circuit]![CircuitPrefix] Forms![ServiceCircuit]![CircuitBase].Requery Forms![ServiceCircuit]![CircuitBase] = Forms![Circuit]![CircuitBase] 'Forms!ServiceCircuit.Refresh Exit Sub Else If IsLoaded("DedicatedService") Then Forms![DedicatedService].Visible = True Forms!DedicatedService.Refresh Exit Sub End If If IsLoaded("Property") Then Forms![Property].Visible = True Forms!Property.Refresh Exit Sub End If End If End Sub Private Sub GRC_GotFocus() Me![GRC].Requery End Sub Private Sub PropBtn_Click() DoCmd.Close If IsLoaded("ServiceCircuit") Then Forms![ServiceCir
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to runtime error 2501 the outputto action was cancelled proceed. To start viewing messages, select the forum that you want to visit from the openform action was cancelled microsoft access 2010 the selection below. Results 1 to 3 of 3 Thread: runtime error 2501 openform action was canceled Tweet Thread Tools ms access error 2501 Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 04-10-13,17:59 #1 rumenrs View Profile View Forum Posts Registered User Join http://stackoverflow.com/questions/14129796/how-to-prevent-openform-action-was-cancelled-in-legacy-access-code Date Apr 2013 Posts 4 Unanswered: runtime error 2501 openform action was canceled Hi, How to fix that? runtime error 2501 openform action was canceled Code: Option Compare Database Option Explicit Private Sub Generate_Click() ' Declare variables Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim varItem As Variant Dim strCriteria As String Dim strSQL As String ' Get the database and stored query Set db = http://www.dbforums.com/showthread.php?1691788-runtime-error-2501-openform-action-was-canceled CurrentDb() Set qdf = db.QueryDefs("q_produkti_print") ' Loop through the selected items in the list box and build a text string If Me!list_names.ItemsSelected.Count > 0 Then For Each varItem In Me!list_names.ItemsSelected strCriteria = strCriteria & "produkti_vav.ID = " & Chr(34) _ & Me!list_names.ItemData(varItem) & Chr(34) & "OR " Next varItem strCriteria = Left(strCriteria, Len(strCriteria) - 3) Else strCriteria = "produkti_vav.ID Like '*'" End If ' Build the new SQL statement incorporating the string strSQL = "SELECT * FROM produkti_vav " & _ "WHERE " & strCriteria & ";" ' Apply the new SQL statement to the query qdf.SQL = strSQL ' Open the query DoCmd.OpenForm "f_produkti_print" ' Empty the memory Set db = Nothing Set qdf = Nothing End Sub Reply With Quote 04-11-13,14:19 #2 tcace View Profile View Forum Posts Registered User Join Date Apr 2004 Location outside the rim Posts 1,011 This line: DoCmd.OpenForm "f_produkti_print" opens the form. The cancel occurs after this line. Either the user is canceling it, or there is something in the Open Event of the form that is setting Cancel = True. I would also look at the SQL string you are assigning to the query - it is possible the SQL statement is in
help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. It's quick & https://bytes.com/topic/access/answers/511913-openform-action-cancelled-2501-a easy. The OpenForm action was cancelled. 2501 P: n/a SDL Help! I have a system that was running fine and I was testing a bottom level form. I went from a https://www.experts-exchange.com/questions/22898313/Run-time-error-'2501'-The-OpenForm-action-was-cancelled.html menu to a screen where I could enter a phone number or name to find a customer. If the customer name hit on more than one person ther is an interim error 2501 selection screen. I have been running thru these screens for 2 days now and everything was fine and suddenly I get "The OpenForm actionwas cancelled." Run Time err 2501? This is happening on several of my OpenForm commands! stLinkCriteria = "CUSTOMER_ID = " & CUSTOMER_ID stDocName = "NEW INVOICE" DoCmd.OpenForm stDocName, , , stLinkCriteria stDocName="NEW INVOICE" stLinkCriteria="CUSTOMER_ID=6" As I said suddenly several time error 2501 similar opens are getting that same error? This is frustrating as hell as I'm fairly new to MS-Access VBA and have a very tight deadline. So far I have found that writing screens 20 years ago on dumb terminals with a home grown database and home grown 'CICS' with Assembler code and 3270 control characters was about the same LOL. Jul 14 '06 #1 Post Reply Share this Question 4 Replies P: n/a Allen Browne Access is informing you that the form/report did not open, so the logic in your code does not blithely proceed assuming that it is now open. If you don't care, just trap Error 2501, and ignore it. If error handling is a new concept, there's a skeleton outline in this article Error Handling in VBA at: http://allenbrowne.com/ser-23a.html It also explains how to call a generic error handler that ignores the error, and logs errors if you want that too. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "SDL" 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 '2501': The OpenForm action was cancelled Want to Advertise Here? Solved Run-time error '2501': The OpenForm action was cancelled Posted on 2007-10-17 MS Access 5 Verified Solutions 5 Comments 4,287 Views Last Modified: 2010-05-18 Users get the run time error in 2003 when trying to open a form called frmDayHistory. Funny thing is it doesnt happen in 2007, and was thinking it may be reference llibrary?? just guessing... Anyway here is the code which fails on the very last line "Docmd.Openform"... Private Sub Command6_Click() Dim BCSDb As DAO.Database Dim RSPN As DAO.Recordset Dim sqlinfo As String Dim strReportDate As String Dim ReportDate As String If Len(Me.TxtDate & vbNullString) = 0 Then MsgBox "Please ensure that a report date is entered into the form", _ vbInformation, "Required Data..." Exit Sub Else 'strReportDate = Day(CDate(Me.TxtDate)) & "/" & _ 'Month(CDate(Me.TxtDate)) & "/" & _ 'Year(CDate(Me.TxtDate)) strReportDate = Month(CDate(Me.TxtDate)) & "/" & _ Day(CDate(Me.TxtDate)) & "/" & _ Year(CDate(Me.TxtDate)) ReportDate = "(#" & strReportDate & "#)" 'MsgBox ReportDate, vbInformation DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE tblDate SET ReportDate = " & ReportDate & "" End If sqlinfo = "SELECT * FROM tblScrapRecords WHERE Date = " & ReportDate & "" 'MsgBox sqlinfo, vbInformation Set BCSDb = CurrentDb Set RSPN = BCSDb.OpenRecordset(sqlinfo, dbOpenSnapshot) If RSPN.BOF = True And RSPN.EOF = True Then MsgBox "There are no records for " & Me.TxtDate & ". Please e