Wrox Programmer Forums
|
BOOK: Access 2010 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2010 Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison; ISBN: 978-0-470-59166-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2010 VBA Programmer's Reference 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 November 24th, 2011, 08:25 AM
Registered User
 
Join Date: Dec 2008
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Is the dialog form still loaded?

I am using Access 2010.
Some form A opens form B in dialog mode. When A gets control back from the call, B is either loaded or unloaded. If (and only if) B is loaded, A can access to the fields within B. How can A determine if B is loaded?
The no-brainer solution is to create a public variable (outside of B) that B can set and A can read. But, passing data through a global variable tightens the coupling between A and B. Instead of becoming a reusable, custom dialog box, B becomes anchored to A through the global variable.
Is there an IsLoaded(Form) Boolean function that can make the determination? Then, B can us IsForm(A) to make the determination.
Is there a way to get form B to propagate an error to A? The error would indicate that the form is no longer loaded. Then, A can handle the error from B. I was unable to get that to work. See below.
Is there a way A can pass a call by reference parameter to B? Then, A can provide an out parameter to B. Openargs lets you pass a string by value?
Here is what nappen when I tried the error propagation proposal.
If form B raises an error in Form_Close, control doesn’t resume at the A’s error handler.
In the VB Editor, under Tools->Options->General, the error trapping is set to “Break on Unhandled Errors”.
In the call stack, the Form_Open call is under the Form_Close subroutine making the raise call.
It behaves like the error is unhandled. But the caller has an error handler. I tested the handling mechanism by raising an error directly in Form_Open. The handler does function.
 
Old November 28th, 2011, 10:37 AM
Registered User
 
Join Date: Nov 2011
Posts: 6
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You may use a code like this
Code:
Function Isopen(formname As String) as Boolean
    
    Dim f As Form
    Isopen = False
    For Each f In Forms
        If formname = f.Name Then
            Isopen = True
            Exit For
        End If
    Next f
    Exit Function
This function returns True if the form is open, else it returns False.

Good luck





Similar Threads
Thread Thread Starter Forum Replies Last Post
Buttons disappear from dialog form j0hnyager Visual Basic 2005 Basics 2 March 3rd, 2008 02:24 PM
replace Word dialog with my designing dialog doublelucky Visual C++ 0 March 19th, 2007 02:27 AM
How to pop up a web form as a modal dialog box?? kv Priya ASP.NET 1.0 and 1.1 Professional 2 June 27th, 2006 07:01 AM
Check whether a form is already loaded madhukp VB How-To 1 September 8th, 2004 11:34 PM
How can i know that a form is loaded. sharma_atin VB How-To 1 September 1st, 2003 10:51 AM





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