Tuesday, January 17, 2012

Function to Close All Forms

The CloseAllForms Function article posted in the UA Wiki  is a handy tool to close all active forms opened with the DoCmd.Open method.

The example code provided in the article includes optional arguments for excluding selected forms from being closed which is an added flexibility bonus.

This function can be modified to close only the forms named in the arguments instead by altering the following line of code found in the example:

If InStr(1, strExcluded, cDelimiter & Forms(intX).Name & cDelimiter, vbTextCompare) = 0 Then
The above If statement checks for and excludes any forms named as arguments when calling the form.  To close only the forms named as arguments instead change the = 0 to <>0 as follows:
If InStr(1, strExcluded, cDelimiter & Forms(intX).Name & cDelimiter, vbTextCompare) <> 0 Then
See the AccessInsider blog for additional tips or visit the examples page for free functional example downloads.

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More