[AccessD] subform close ...solved

William Hindman wdhindman at dejpolsystems.com
Wed Jan 21 17:19:17 CST 2009


Max

...agreed ...in this specific instance I don't ...but in many instances I 
will need to ensure the form is closed in the proper manner because the 
source object can be reset at any time by the user by selecting another node 
in the host form's treeview ...the docmd.close in this instance serves to 
remind me that cleanup is necessary and allows consistency when transferring 
this into a case function in a module.

...we'll disagree on the parent argument ...jc's example did not identify a 
problem with using parent, only that you must understand that a tab control 
is the parent to subforms embedded in it ...using parent rather than the 
specific host form name allows me to substantially reduce the code required 
when transferring this to a module.

...I'll take a look at the args methods in a few days when I get the rest of 
this gui straightened out and start to do real things with it.

...tks

William

--------------------------------------------------
From: "Max Wanadoo" <max.wanadoo at gmail.com>
Sent: Wednesday, January 21, 2009 5:03 PM
To: "'Access Developers discussion and problem solving'" 
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] subform close ...solved

> William,
> I don't think you don't need the docmd.close line.
> Also, if you use me.parent you cannot be absolutely sure that it is 
> pointing
> to where you *think* it is (see JC's comment earlier).  I would suggest 
> you
> use the structure when the main form is named.
>
> Args can be *stored* and then read from the main form be subforms (or use
> global vars), or use a text file or use a table (access uses tables)
>
> Max
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Hindman
> Sent: 21 January 2009 21:19
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] subform close ...solved
>
> ..just to finalize this thread, the following code works totally from 
> within
>
> the subform ...don't have to move focus or use the host ...click on the 
> cmd
> button and the first line works to cleanup the subform itself ...then the
> second line removes the form from the parent subform control and replaces 
> it
>
> with my "big ugly blank" ...or anything you want
>
> Private Sub cmdClose_Click()
> On Error GoTo Err_cmdClose_Click
>
>
>    DoCmd.Close acForm, "frm_SystemColors_sub", acSaveNo
>    Me.Parent!Switchboard_Subform.SourceObject = "frm_Main_sub"
>
> Exit_cmdClose_Click:
>    Exit Sub
>
> Err_cmdClose_Click:
>    MsgBox Err.Description
>    Resume Exit_cmdClose_Click
>
> End Sub
>
> ...next is figuring out how to pass openargs from subform to subform when
> necessary.
>
> ...thanks to all who responded.
>
>
> William
>
> --------------------------------------------------
> From: "Max Wanadoo" <max.wanadoo at gmail.com>
> Sent: Wednesday, January 21, 2009 2:11 PM
> To: "'Access Developers discussion and problem solving'"
> <accessd at databaseadvisors.com>
> Subject: Re: [AccessD] subform close
>
>> Or just load it directly with this....
>>
>> [Forms]![MyMainFormName]![MyHostCotainerOnMainFormName].SourceObject =
>> "myDefaultBlankForm"
>>
>> Max
>>
>>
>> -----Original Message-----
>> From: accessd-bounces at databaseadvisors.com
>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William 
>> Hindman
>> Sent: 21 January 2009 19:01
>> To: Access Developers discussion and problem solving
>> Subject: Re: [AccessD] subform close
>>
>> JC/max
>>
>> ...thanks ...that works for now ...I was close but my syntax wasn't
>> getting
>> it done.
>> ...as for the "big ugly blank" concern I have a default form that
>> automatically loads whenever the subform control is empty.
>>
>> William
>>
>> --------------------------------------------------
>> From: "Max Wanadoo" <max.wanadoo at gmail.com>
>> Sent: Wednesday, January 21, 2009 12:49 PM
>> To: "'Access Developers discussion and problem solving'"
>> <accessd at databaseadvisors.com>
>> Subject: Re: [AccessD] subform close
>>
>>> This will do what you require William.
>>>
>>> [Forms]![MyMainFormName]![MyHostCotainerOnMainFormName].SourceObject = 
>>> ""
>>>
>>> Ie, on my system this translates into
>>>
>>> [Forms]![MCM_Peoplemainform]![PeoplePopSub2].SourceObject = ""
>>>
>>> I would normally have a series of buttons on the main form and when
>>> clicked
>>> the sourceobject is changed to the name of the form I want to appear, 
>>> but
>>> setting it to "" works even when invoked from the sub form itself.
>>>
>>>
>>> Max
>>>
>>> -----Original Message-----
>>> From: accessd-bounces at databaseadvisors.com
>>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William
>>> Hindman
>>> Sent: 21 January 2009 17:36
>>> To: Access Developers discussion and problem solving
>>> Subject: Re: [AccessD] subform close
>>>
>>> ...why does anyone? ...like all programmers I'm a masochist at heart :)
>>>
>>> ...experimenting with a new gui ...need to work out the kinks :)
>>>
>>> ...and I'm working on just that approach :)
>>>
>>> William
>>>
>>> --------------------------------------------------
>>> From: "Gustav Brock" <Gustav at cactus.dk>
>>> Sent: Wednesday, January 21, 2009 4:33 AM
>>> To: <accessd at databaseadvisors.com>
>>> Subject: Re: [AccessD] subform close
>>>
>>>> Hi William
>>>>
>>>> Why are you doing this to yourself?
>>>>
>>>> That said, you may have to move the focus off the button as the first
>>>> thing.
>>>> Then, shouldn't this work? Haven't tried myself though:
>>>>
>>>>  Me.Parent!NameOfSubformControl.Value = strNameOfNewSubform
>>>>
>>>> or
>>>>
>>>>  Me.Parent!NameOfSubformControl.Value = Null
>>>>
>>>> You may need to move the code to the main form and call it from the
>>>> subform to not let the subform kick the feet of itself away.
>>>>
>>>> /gustav
>>>>
>>>>
>>>>>>> wdhindman at dejpolsystems.com 21-01-2009 08:26 >>>
>>>> ...closes host and sub :(
>>>>
>>>> ...naming the sub instead doesn't change what I see ...the acSaveAll
>>>> works,
>>>> the form just doesn't disappear from the subform control
>>>>
>>>> ...if I change the mainform subform sourceobject from the host form, 
>>>> the
>>>> form is either replaced by the new sourceobject or the subform goes
>>>> blank
>>>> if
>>>> I set it to ""
>>>>
>>>> ...but that leaves me vulnerable to users closing an open subform from
>>>> the
>>>> host form without a proper close
>>>>
>>>> ...trying to workout the semantics for setting the mainform subform
>>>> sourceobject from the subform ...this should be simple but I'm missing
>>>> something.
>>>>
>>>> William
>>>>
>>>> --------------------------------------------------
>>>> From: "Rocky Smolin at Beach Access Software" <rockysmolin at bchacc.com>
>>>> Sent: Wednesday, January 21, 2009 12:08 AM
>>>> To: "'Access Developers discussion and problem solving'"
>>>> <accessd at databaseadvisors.com>
>>>> Subject: Re: [AccessD] subform close
>>>>
>>>>> Wait, I see.  I think you have to specify the form name of the host
>>>>> form:
>>>>> DoCmd.Close acForm, ObjectName
>>>>>
>>>>>
>>>>> Rocky Smolin
>>>>> Beach Access Software
>>>>> 858-259-4334
>>>>> www.e-z-mrp.com
>>>>> www.bchacc.com
>>>>>
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: accessd-bounces at databaseadvisors.com
>>>>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William
>>>>> Hindman
>>>>> Sent: Tuesday, January 20, 2009 8:47 PM
>>>>> To: Access Developers discussion and problem solving
>>>>> Subject: [AccessD] subform close
>>>>>
>>>>> ...subform hosted on non-linked main form
>>>>>
>>>>> ...command button on subform
>>>>>
>>>>> DoCmd.Close ...button animates but form doesn't close
>>>>>
>>>>> ...thinking that I'm probably going to have to set the mainform 
>>>>> subform
>>>>> sourceobject to "" or another object and clean up anything on the open
>>>>> subform such as dirty data before I do it.
>>>>>
>>>>> ...anyone done this and have tested code or suggestions?
>>>>>
>>>>> William
>>>>
>>>>
>>>> -- 
>>>> 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
>>>
>>> -- 
>>> 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
>>
>> -- 
>> 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
>
> -- 
> 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