?
Solved

How to save the active form

Posted on 2003-02-28
4
Medium Priority
?
221 Views
Last Modified: 2012-05-04
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
Comment
Question by:katzwhite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8044979
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
 

Author Comment

by:katzwhite
ID: 8045059
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
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 1200 total points
ID: 8045105
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
 

Author Comment

by:katzwhite
ID: 8045387
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question