A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how can I programatically close a subform



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2006, 10:49 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

how can I programatically close/open a subform
  #2  
Old February 8th, 2006, 11:07 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

A subform is not "open" (not part of the Forms collection), so you cannot
open or close it.

You can hide it by toggling the Visible property of the subform control.

Or you can load/unload it by setting/clearing the SourceObject property of
the subform control. If you do set the SourceObject, Access will have a
guess at what you want for the LinkMasterFields/LinkChildFields, but it may
not be what you intend.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"simcon" wrote in message
...
how can I programatically close/open a subform



  #3  
Old February 22nd, 2006, 07:50 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

i have a related question that perhaps you can answer. At runtime, I create
a form and populate it with various controls, including one subform (for
which I also set the SourceObject property).

At the end of the sub which does all of this I have the command

DoCmd.Close acForm, frm.Name, acSaveYes

I was expecting the new form to be saved without a prompt, but I get a
prompt asking to save both the form and its embedded subform. If I don't add
the subform, I am not prompted.

Any ideas how to suppress the save prompt, which seems to be caused by the
subform?

thanks
--
dchman


"Allen Browne" wrote:

A subform is not "open" (not part of the Forms collection), so you cannot
open or close it.

You can hide it by toggling the Visible property of the subform control.

Or you can load/unload it by setting/clearing the SourceObject property of
the subform control. If you do set the SourceObject, Access will have a
guess at what you want for the LinkMasterFields/LinkChildFields, but it may
not be what you intend.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"simcon" wrote in message
...
how can I programatically close/open a subform




  #4  
Old February 23rd, 2006, 02:36 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

You explicitly saved the main form.

If you created a subform as well, did you explicitly save that as well?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dchman" wrote in message
...
i have a related question that perhaps you can answer. At runtime, I
create
a form and populate it with various controls, including one subform (for
which I also set the SourceObject property).

At the end of the sub which does all of this I have the command

DoCmd.Close acForm, frm.Name, acSaveYes

I was expecting the new form to be saved without a prompt, but I get a
prompt asking to save both the form and its embedded subform. If I don't
add
the subform, I am not prompted.

Any ideas how to suppress the save prompt, which seems to be caused by the
subform?

thanks
--
dchman


"Allen Browne" wrote:

A subform is not "open" (not part of the Forms collection), so you cannot
open or close it.

You can hide it by toggling the Visible property of the subform control.

Or you can load/unload it by setting/clearing the SourceObject property
of
the subform control. If you do set the SourceObject, Access will have a
guess at what you want for the LinkMasterFields/LinkChildFields, but it
may
not be what you intend.

"simcon" wrote in message
...
how can I programatically close/open a subform



  #5  
Old February 23rd, 2006, 01:51 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

No. I add the subform with a line like;

Set ctl = CreateControl(frm.Name, acSubform, acDetail, , "", iLP, iTP, iWP,
iHP)

then I set its source object to an existing form;

ctl.SourceObject = "sfrmSubDisplay"

Then I modify some of the properties for controls on the subform with code
like;

frm.Controls(ctl.Name).Form.Controls("txt1").Width = 250

When complete I close the form with

DoCmd.Close acForm, frm.Name, acSaveYes

At runtime, when this line is processed, the prompt appears asking to save
both the form and subform. If I don't modify any of the control properties
on the subform, I don't get the prompt. If I add a DoCmd.SetWarnings False,
I don't get the prompt and any properties I've modified on the subform are
saved.

Should I just use the DoCmd.SetWarnings False to suppress the prompt? Or do
you recommend that I save the subform explicitly, and if so, can you give me
a code example?

Thanks
--
dchman


"Allen Browne" wrote:

You explicitly saved the main form.

If you created a subform as well, did you explicitly save that as well?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dchman" wrote in message
...
i have a related question that perhaps you can answer. At runtime, I
create
a form and populate it with various controls, including one subform (for
which I also set the SourceObject property).

At the end of the sub which does all of this I have the command

DoCmd.Close acForm, frm.Name, acSaveYes

I was expecting the new form to be saved without a prompt, but I get a
prompt asking to save both the form and its embedded subform. If I don't
add
the subform, I am not prompted.

Any ideas how to suppress the save prompt, which seems to be caused by the
subform?

thanks
--
dchman


"Allen Browne" wrote:

A subform is not "open" (not part of the Forms collection), so you cannot
open or close it.

You can hide it by toggling the Visible property of the subform control.

Or you can load/unload it by setting/clearing the SourceObject property
of
the subform control. If you do set the SourceObject, Access will have a
guess at what you want for the LinkMasterFields/LinkChildFields, but it
may
not be what you intend.

"simcon" wrote in message
...
how can I programatically close/open a subform




  #6  
Old February 23rd, 2006, 02:16 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I programatically close a subform

If turning off SetWarnings suppresses the warnings and gives the desired
results, just go ahead and do that.

(I can't say that I generate forms on the fly often, other than for
demonstration purposes, or creating Wizard-type interfaces. For commercial
applications, I always use an MDE.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dchman" wrote in message
...
No. I add the subform with a line like;

Set ctl = CreateControl(frm.Name, acSubform, acDetail, , "", iLP, iTP,
iWP,
iHP)

then I set its source object to an existing form;

ctl.SourceObject = "sfrmSubDisplay"

Then I modify some of the properties for controls on the subform with code
like;

frm.Controls(ctl.Name).Form.Controls("txt1").Width = 250

When complete I close the form with

DoCmd.Close acForm, frm.Name, acSaveYes

At runtime, when this line is processed, the prompt appears asking to save
both the form and subform. If I don't modify any of the control
properties
on the subform, I don't get the prompt. If I add a DoCmd.SetWarnings
False,
I don't get the prompt and any properties I've modified on the subform are
saved.

Should I just use the DoCmd.SetWarnings False to suppress the prompt? Or
do
you recommend that I save the subform explicitly, and if so, can you give
me
a code example?

Thanks
--
dchman


"Allen Browne" wrote:

You explicitly saved the main form.

If you created a subform as well, did you explicitly save that as well?

"dchman" wrote in message
...
i have a related question that perhaps you can answer. At runtime, I
create
a form and populate it with various controls, including one subform
(for
which I also set the SourceObject property).

At the end of the sub which does all of this I have the command

DoCmd.Close acForm, frm.Name, acSaveYes

I was expecting the new form to be saved without a prompt, but I get a
prompt asking to save both the form and its embedded subform. If I
don't
add
the subform, I am not prompted.

Any ideas how to suppress the save prompt, which seems to be caused by
the
subform?

thanks
--
dchman


"Allen Browne" wrote:

A subform is not "open" (not part of the Forms collection), so you
cannot
open or close it.

You can hide it by toggling the Visible property of the subform
control.

Or you can load/unload it by setting/clearing the SourceObject
property
of
the subform control. If you do set the SourceObject, Access will have
a
guess at what you want for the LinkMasterFields/LinkChildFields, but
it
may
not be what you intend.

"simcon" wrote in message
...
how can I programatically close/open a subform



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
my data doesn't save in the subform when I close the form Jerry Using Forms 1 December 28th, 2005 02:27 AM
open subform in new window or as form PCC Ken Using Forms 0 August 1st, 2005 09:59 PM
ECHO Causing Problems DS General Discussion 5 May 17th, 2005 02:19 AM
dlookup miaplacidus Using Forms 9 August 5th, 2004 09:16 PM
Recordset in subform based on field in parent form Lyn General Discussion 15 June 14th, 2004 03:10 PM


All times are GMT +1. The time now is 07:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.