Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: closing all open forms in one operation


Message #1 by "Howard Stone" <ququmber@h...> on Fri, 19 Apr 2002 04:54:40
I have a db in which I would like a cmdButton to close all forms except a 
form named frmSwitchboard.  I attach the procedure below to the OnClick 
event of a cmdButton.


Dim frm As Form
For Each frm In Forms
    If frm.Name <> "frmSwitchboard" Then
        DoCmd.Close acForm, frm
    End If
Next frm

    

I am getting a error message saying it is the wrong data type for the 
argument.

What is the correct syntax?

Thanks
Message #2 by "Ian Ashton" <ian@c...> on Fri, 19 Apr 2002 06:51:05 +0100
Use:  DoCmd.Close acForm, frm.Name

Ian Ashton

-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Friday, April 19, 2002 4:55 AM
To: Access
Subject: [access] closing all open forms in one operation


I have a db in which I would like a cmdButton to close all forms except a 
form named frmSwitchboard.  I attach the procedure below to the OnClick 
event of a cmdButton.


Dim frm As Form
For Each frm In Forms
    If frm.Name <> "frmSwitchboard" Then
        DoCmd.Close acForm, frm
    End If
Next frm

    

I am getting a error message saying it is the wrong data type for the 
argument.

What is the correct syntax?

Thanks
Message #3 by "Ian Tamburello" <formatian@a...> on Fri, 19 Apr 2002 12:27:36
Try:

Dim frm As Form
For Each frm In Forms
    If frm.Name <> "frmSwitchboard" Then
        DoCmd.Close acForm, frm.Name
    End If
Next frm

The Docmd.Close object expects a string so frm.Name will work.

Ian

  Return to Index