william.thompson1 at att.net
william.thompson1 at att.net
Fri Nov 19 19:51:52 CST 2004
Yes, that does make sense. I think what threw me at first was seeing 'SetFocus' as in: set ....etc Form_FrmSome.Setfocus I realize now that's how control is passed to the instance. The visible property happens later, and in the new instance itself. me.visible = true I understand now that a Public Function is built in the new instance form, which allows it to retain a reference to itself, and that a reference could not be passed via openargs. Another part of this that is always tricky for me is that a form's Public Function can be called when it is not loaded. It's not hidden in this pristine state, yet it remains unloaded and can cycle through records. I think ideally I'd like to have, as you describe, the close button set the reference = nothing Thanks, Bill -------------- Original message from "Colby, John" <JColby at dispec.com>: -------------- > 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 > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com