Learn Microsoft Access Advanced 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

Translate



PageRank
Subscribe in a reader
Your email address:

Delivered by FeedBurner

Search

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

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

Featured Post

WithEvents and Defining your own Events

Hope that you have gone through last week’s WithEvents, Event, RaiseEvent introduction, tried out the sample Forms and understood as how bo...

Labels

Blog Archive

Recent Posts