Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2004, 06:31 PM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine if a form is open

I have a main form (Form1) to enter information into table1. One field is linked to table2. TO add information to table2 you can click on a macro button in form1 to open a new form (form2) to add information to table2. After you enter your information into form2 and click on the close button the linked information in Form1 is not updated. you can not see the information that you just added. I have added code into form2's close button to refresh form1. That works as long as form1 is open. Is there a way to add a if then else statment to determine if form1 is open. something like. if (form1 is open) then refresh form1 else close form. Any help will be GREAT!!

Thanks in advance

 
Old October 7th, 2004, 04:59 PM
Authorized User
 
Join Date: Oct 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have your code call a function named IsFormOpen - the call would
look something like this:

If IsFormOpen("form_name") = True Then ...
   your_code_goes_here
End If

Declare a public function named IsFormOpen() - here's the code:

Public Function IsFormOpen(ByVal strObjectName As String) As Boolean

    If SysCmd(acSysCmdGetObjectState, acForm, strObjectName) = acObjStateOpen Then
       If Forms(strObjectName).CurrentView = 1 Then
          IsFormOpen = True
       Else
          IsFormOpen = False
       End If
    End If

End Function





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open one form or the other mean34dean Access VBA 4 August 21st, 2008 12:02 PM
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Close all MdiChield form from open one form salman .NET Framework 1.x 0 November 8th, 2007 12:32 AM
Open Form, run query, open form Grafixx01 Access 7 April 26th, 2007 11:32 AM
determine if an invisibile form is open Loralee Access 12 February 25th, 2006 09:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.