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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
how can I programatically close a subform
how can I programatically close/open a subform
|
#2
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 01: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 |