[AccessD] Finite instances of form in Edit, Add modes - Clos e cmdButton?

Colby, John JColby at dispec.com
Fri Nov 19 09:47:21 CST 2004


A form opened in this manner has to have a pointer to the form stored
somewhere in order to remain open.  As soon as the last pointer to that form
is set to nothing, the form will close.

One way to keep the form open is to pass the pointer to the form in to the
form, where it stores the pointer to itself in its header. The close button
does nothing more than set that pointer = nothing.  That allows the form to
close itself.

It is not possible to pass pointers as openagrs, the data type of an openarg
is a string.  Thus you have to build a public function in the form being
opened that can be called and a pointer passed in, or the form being opened
has to reach back to the opening form and ask for the pointer to itself.  

The other way is to have the calling form to store the pointer to the form,
but now the calling form has to close the new form by setting the pointer to
nothing.

Does all this make sense?

John W. Colby
The DIS Database Guy


-----Original Message-----
From: William Thompson [mailto:william.thompson1 at att.net]
Sent: Friday, November 19, 2004 10:24 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Finite instances of form in Edit, Add modes -
Close cmdButton?


Hi,
I have a SQL Server front-end that has to be a minimal code solution, and I
wanted to open a form, form_someform, with openargs "Edit" or "Add".

I don't want the user to have to 'x' out to close the form instance.  There
would only be the two additional instances.

My question is how to handle the close button in the new instance.  Am I
correct to presume that I have to pass the new instance a reference to
itself in order to hand control back to the caller?

The call to open the instance would be something like

Dim frmSomeTable As Form_SomeTable

 Set frmSomeTable = New Form_SomeTable

Form_SomeTable.Setfocus

Set Form_SomeTable = Nothing

''' I think the new instance needs a Method like

public sub InstanceIt(TheCaller as form)
    
    Set m_frmThis = Me
    
    Set m_frmCaller = TheCaller
    
    Me.Visible = True

end sub

''' So eventually I'd like to somehow have a command button that closes the
form sort of like..

Private Sub cmdCloseThis()

'''	Set m_frmThis = Nothing

''' Or I guess it has to be
''' HandItBackToTheCaller
me.Hide

m_frmCaller.SetFocus

End Sub

''' Caller's Code continued ...
Set Form_SomeTable = Nothing

This won't work though will it ?  I'm a little fuzzy on it, any help
appreciated.

Bill

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list