Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

How to save the active form

I open a form, resize it with the code below and then try to save the resized form under a new name.

The code below copies the original form instead of the modified form to the new name .  How do I save the modified form under the new name?

Private Sub Command53_Click()
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Const conTempPrint = "TempToPrint"
Dim X As Integer, Y As Integer, cx As Integer, cy As Integer

X = 0
Y = 0
cx = 700
cy = 950
xg_SizeWindow "Active", X, Y, cx, cy

  DoCmd.CopyObject , frmCurrentForm.Name + conTempPrint, acForm, frmCurrentForm.Name

End Sub

Thanks

Elton
0
katzwhite
Asked:
katzwhite
  • 2
  • 2
1 Solution
 
shanesuebsahakarnCommented:
You can't really do this from the active form. In order to be able to save changes to a form, you must open it in design view, so you'd need to place the resizing code in a different form than the one you want to save. You'd then need to open your target form in design view (which you can do using DoCmd.OpenForm), make your changes and then save it.
0
 
katzwhiteAuthor Commented:
shanesuebsahakam,

You may be right, but the Help for the close cmd seems to allow saving a modified form "See Below".  I just need to change the name to keep from overwriting the original form.

"Close Method Example

The following example uses the Close method to close the form Order Review, saving any changes to the form without prompting:

DoCmd.Close acForm, "Order Review", acSaveYes"

Also since this is running in VBA and needs to be hidden from the user, the design view suggestion won't work.  Hopefully someone knows how to do this.

Thanks

Elton
0
 
shanesuebsahakarnCommented:
The help file is slightly misleading in that the acSaveYes does work, but only for the form in design view.

You can open a form in design view and still have it hidden from the user like this:
DoCmd.OpenForm "MyForm",acDesign,,,,acHidden

You can then make any changes you need and close the form with the acSaveYes argument, which will cause any programmatic changes you make to the form to be saved.

In order to prevent the original from being overwritten, use the CopyObject to copy the original to a temporary name. Save the changed version (this will overwrite the original). You can now use the DoCmd.Rename statement to name the overwritten original to your new desired name, and the copy to the original name.
0
 
katzwhiteAuthor Commented:
shanesuebsahakarn,

That's a more indirect route than I had hoped for, but I now understand what you were trying to tell me about having to be in design mode.  

Thanks

Elton
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now