Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prompted to save subform when closing mainform

Status
Not open for further replies.

uguimess

Technical User
Jul 29, 2009
24
0
0
CA
I posted this question in the wrong forum here. So here is the gist...
when programmatically closing a form on which I just programmatically added controls to its subform, I am prompted to save. How can I skip the prompt and save, ...programmatically of course?


-----------------------------------------
Where would we be if we didn't try?
 
DoCmd.Close acForm, "Formname", acSaveYes

will do it normally, I'm not sure though whether this will work with a subform or a main form only.
I should point out that if you are running through the runtime version of Access this won't work, as modifying form design and saving objects is not permitted.

John
 
Wow. Thanks.

I was planning to package it and send with the runtime. I will have to rework this.

By reading my misplaced post, which is linked to, above, you will see that I used the docmd. statement you prescribed. It isn't working.

-----------------------------------------
Where would we be if we didn't try?
 
Your misplaced post linked to has been removed, so I am unable to check the contents of it.

John
 
I knew this was something a heck of a lot simpler than what I was proposing.... in the original post....

Glad the better solution was found.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
How are ya uguimess . . .

[blue]Set focus to a control on the mainform[/blue], then perform the DoCmd.Close acForm, "Formname", acSaveYes.

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hey John.

I just packaged it and opened it on my dev machine and I am able to change the forms, programmatically. Is it bypassing the run-time and running off access, or will this also work on a machine that does not have access installed???

-----------------------------------------
Where would we be if we didn't try?
 
When you use your test machine, make sure the command line to access specifies /runtime

eg (not sure if this is correct but you get the idea):
"C:\Program Files\Microsoft Office\Office11\msaccess.exe" /runtime "H:\MyApp\Database.mdb"

This should force a full copy of access to run with the behaviour of the runtime.

John
 
Thanks AceMan.

The form is in design mode, so I tried switching to preview mode with no joy. Below is the proc that opens the form, tries to save it and then closes it.

Code:
Private Sub ConfigSite()

    Dim iStnID As Integer
    Dim sFrm As String
    Dim iSiteGrouping As Integer
    
    iSiteGrouping = Me.GpSiteGrouping
    sFrm = "frm_Data_Entry_Main"
    
    DoCmd.OpenForm sFrm, acDesign, , , , acHidden
    
    iStnID = DLookup("A_Value", "A_Admin", _
             "Domain = 'frm_Data_Entry_Main' AND A_Item = 'Default_Station'")
    Call CreateMyControl(iStnID, iSiteGrouping)
    
    DoCmd.OpenForm sFrm, acNormal, , , , acHidden
    Forms!frm_Data_Entry_Main!txtStation.SetFocus
    DoCmd.Close acForm, sFrm, acSaveYes
    DoCmd.OpenForm sFrm, acNormal, , , , acWindowNormal

End Sub

-----------------------------------------
Where would we be if we didn't try?
 
Solved.
Works fine by settings Warnings to False.

-----------------------------------------
Where would we be if we didn't try?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top