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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save/ Rename Form 1

Status
Not open for further replies.

xweyer

MIS
Sep 7, 2000
140
US
Is it possible to save and/or rename an Access form using VBA?

I was considering the possibility of creating a 'template' form which would have particular control properties modified (via code) based on specific conditions and then saving the modified form under another name for later use.

I've done some searching on the subject but couldn't find an answer.

 
try
Code:
Dim frm As Access.Form
Dim oldname As String
Set frm = CreateForm(, "form1")
DoCmd.Save acForm, frm.Name
oldname = frm.Name
DoCmd.Close acForm, frm.Name
DoCmd.Rename "newname", acForm, oldname
 
Thanks for the tip. The Renaming worked perfectly.

The CreateForm method didn't give me the results I was seeking. After some trial and error it appears that the form that is created from the template only copies over some of the templates' properties. In the template form I was using the dimensions and background color were carried over to the new form but all of the original's controls along with some of its other properties were dropped.

Your suggestion was still helpful though because it lead me to some information I had not found in my previous search.

Right now I'm experimenting with DoCmd.CopyObject which I think I should be able to combine with .Rename to produce the results I was after.

Since I understand there may be some "bloating" issues with this approach I'm may also take a crack at one of these means as an alternative.


Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top