470

How to close (unload) a form

Question:

I have a form that has some buttons, and when user click on a button, the form should be closed (unloaded). I used the following methods, but all generate error:

docmd.close me unload me

What is the best way to close or unload a form in VBA (from code inside the form)

Answer1:

DoCmd.Close expects <em>ObjectType</em> as its first argument, followed by <em>ObjectName</em> which is a variant string as the object name.

So in the click event of a command button which is intended to close the current form, I use this ...

<pre class="lang-vb prettyprint-override">DoCmd.Close acForm, Me.Name

Recommend

  • Docmd.TransferText to update data
  • Maintain horizontal and vertical ScrollPosition on Postback in ASP.NET
  • Can't unload kext while installing VirtualBox 4.3.6
  • Google App Engine Payload Object
  • How to change file type in solution explorer from Form to Class
  • bind checkbox with a bit column in a SQL Server linked table
  • No OpenID endpoint found - Relying Party Timeout Option
  • VBA fails when Task Scheduler is set to “Run whether user logged on or not”
  • Index 1 is either negative or above rows count
  • IdentityServer3 - redirect to ADFS if client is on intranet
  • ReplaceWith carousel-inner with new items
  • Scroll down whole browser window
  • Android fade in not working
  • Rails 4.0.0 jQuery Mobile button icons not showing in production
  • Update SQL MS Access 2010
  • UI-GRID column summation on checkbox change
  • qt how to know that a pushbutton is clicked?
  • Each Radiobutton for each form or 1 Form for all radiobuttons?
  • How to name a 'group' check box in Adobe Reader when wanting to fill form by FDF / XFDF
  • Creating a Multi-Step Modal Using Jquery
  • SetWindowsHookEx does not react on media keys
  • Debug.DrawLine not showing in the GameView
  • Android full screen on only one activity?
  • Optimizing database types to compact database (SQLite)
  • TFS: Get latest causes slow project reloading
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Running a C# exe file
  • Adding custom controls to a full screen movie
  • Is there a mandatory requirement to switch app.yaml?
  • Cannot Parse HTML Data Using Android / JSOUP
  • C# - Getting references of reference
  • Hits per day in Google Big Query
  • Why joiner is not used after Sequence generator or Update statergy
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Reading document lines to the user (python)
  • Android Heatmap on canvas or ImageView
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF