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 December 16th, 2004, 10:52 AM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to chonny_78
Default How to chech if form is open

How to chech if form is open. ACCESS 2000
 
Old December 16th, 2004, 04:01 PM
Authorized User
 
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

You need to use the Access Forms collection.

......

Dim n as object
dim formname as string
.......

formname = "name of form you are trying to find"

for each n in currectdb.forms
  if n.name = formname then
     MsgBox "Form " & n.name & " exists and is open"
     goto foundit
   end if
next n

msgbox "Form " & formname & " is not open"
exit sub

foundit: .....
   rest of code

Very simple, but works every time.

Alan Thomas















 
Old December 17th, 2004, 12:26 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Chonny,

Pass the form name to the following function. Function will return true if form is open and false otherwise.

Function IsFormOpen(ByVal strFormName As string) As Integer
   If SysCmd(acSysCmdGetObjectState, acForm,strFormName) <> 0 Then
      If Forms(strFormName).CurrentView <> 0 Then
         IsFormOpen = True
      End If
   End If
End Function

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





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 a form is open Danton Access VBA 1 October 7th, 2004 04:59 PM





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