Ms-Access Advanced VBA Programming Techniques, Tips and Tricks.

Closing Forms

For closing an active Access Form we can use several methods and apply certain tricks to enhance the overall look of the action used for it.

The simplest method is to click the window close button X, which everybody knows. The On Close Event of the Form is also triggered on this action and the programmer can take care of any unfinished work like closing of other forms related to the main form etc. But, when more Forms are open at the same time then there is a chance that the user may close the wrong Form by clicking on the wrong X button on the top.

I prefer to create a Command Button on a convenient location on the Form, like at the Footer or Header of the Form and let the user click on it. Create a macro and link to the Command Button's Hyperlink SubAddress Property. My favourite name for the Macro is Hlink_Close and it will contain only the Close Action leaving the ObjectType and ObjectName parameters blank.

Click on the Hyperlink SubAddress Property of the Command Button and click on the build ... icon at the right side to open up the Edit HyperLink Dialog Control. Select the Object in this Database option from the Link To: Option List which will show the Database Objects: Tables, Forms etc., expand the Macro group and select the HLink_Close Macro and click OK.

This method has an attractive feature, when you point to the control with the Hyperlink SubAddress set with the Macro, the Cursor changes to a hand with the index finger pointing, as you see when you point the cursor on a Hyperlink in Internet.

The same HLink_Close Macro can be used this way for any number of Forms on it's Command Buttons, Labels, Images, or any other Object that has a Hyperlink SubAddress Property, to close a Form by clicking on the object.

This method will not work on a form with the Form's Popup Property set to Yes. In such case, if another form is present with the Form's Popup Property set to No, then that form will be closed leaving the original form untouched. If this is the only form open, then it will end up with an error message: can't follow the Hyperlink Macro Hlink_Close. Use alternative method for Forms with Popup Property set to Yes, like: write an On Click EventProcedure for the Command Button and write a Docmd.Close action in the VB Module without any parameters.

If you need to change only the style of the Mouse Pointer to a hand while pointing the cursor on the control then create a Macro with Action set to Beep or Echo and link this Macro to the controls Hyperlink SubAddress Property. I use the name HLink_Blank for such a Macro with the Action set to Beep. The Beep action will take place only when you click the object.

Tip: You can Open External Files Like Word, Excel etc. by setting the Hyperlink Address Property (not Hyperlink SubAddress) of the Command Button with an external File's location address. Select the Link to Option: Existing File or Webpage rather than Object in this Database from the Edit Hyperlink Dialog Control.

Click Next to see Opening Access Forms

Share:

1 comment:

  1. [...] Solved: Amended macro action to 'Close' leaving the ObjectType and ObjectName parameters blank and deleted all the sub-macros. changed the form's Popup property from Yes to No Made the Hyperlink SubAddress property link to the new Close macro which now has no sub-macros. Found this article helpful: http://msaccesstips.com/2007/05/closing-forms/ [...]

    ReplyDelete

Trending

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

Forms How Tos MS-Access Security Functions Reports Animations msaccess animation msaccess forms Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Queries External Links msaccess reports msaccess tips Menus and Toolbars Accesstips MsaccessLinks Process Controls Art Work Downloads msaccess How Tos Graph Charts msaccessQuery List Boxes Command Buttons Emails and Alerts Query Combo Boxes Custom Wizards msaccess graphs msaccess reporttricks ms-access functions msaccessprocess security advanced Access Security DOS Commands Data Macros Menus Property Report Top Values VBA msaccess email msaccess menus progressmeter Access2007 Array Auto-Number Command Button Join Microsoft Numbering System Records Security Split SubForm Table Utility Workgroup database msaccess functions msaccess wizards Access2003 Accounting Year Action Animation Attachment Binary Numbers Budgeting Calculation ChDir Color Palette Conditional Formatting Controls Copy Custom Functions Data Filtering Data Type Defining Pages Diagram Disk Dynamic Lookup Error Handler Excel Export Expression External Field Type Fields Filter Form Form Instances Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Methods Monitoring Object Reference Objects Octal Numbers Operating System Paste Primary-Key Product Rank Reading Rich Text Sequence SetFocus Summary Tab-Page Time Difference Union Query User Users Variables Water-Mark Word automatically commands function hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar tutorial updating upload vba code

Featured Post

Finding Last Day of Week

How to find the week-end date or first-day date of a week using Current Date as input.  Or find first/last-day date of any week by giving a ...

Labels

Blog Archive

Recent Posts