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

Copying Forms in Design 1

Status
Not open for further replies.

EriRobert

MIS
May 9, 2003
114
GB
Hi

A Grade One question from a beginner but here goes...

In Micorsoft Access within design I am used to copying forms rather than starting from scratch - in Access this is a simple form save-as.

However in Visual Basic the form save-as seems to do something different. It copies the .frm/.frx files on the disk but seems to change the disk name next to the logical original name in Project Explorer. The new form is not added to Project Explorer.

To clarify (hopefully) - [When I want to copy frmA to produce frmB]

Project Explorer:

Start: frmA (frmA.frm)

After Save-as: frmA (frmB.frm)

What I want: frmA (frmA.frm)
frmB (frmB.frm)


I'm sure there is an easy answer to this.


 
If you are not already doing so, (it's difficult to grasp from the wording of your thread) you also need to re-name the form in form properties.
 
Try it in this order:

1: Save Form1 as Form1.

2: Change the name of the form in the properties to Form2.

3: Save as Form2.

4: Open the project menu ( CTRL-R ) and right click to add a form.

5: Choose existing Form1 from wherever it is you saved it in step 1.

You should now have both forms in your project.

Robert
 
Thanks vamp - this works.

Isn't it a bit long-winded? Don't you programmers do this all the time.

In all other applications (word, excel etc.) save-as creates a new version and leaves the original alone.

Anyway its a solution I can work with.
 
EriRobert, Most VB programmers don't do this all the time. In Access you tend to make a lot of forms and might copy them to keep the same look and feel. With VB you tend to write a lot more code per form and often times want each form to be different from the others.
I came from an Access background and really ran into the exact same thing as you just did. I ened up really screwing up a project, but fortunatly had checked it in to source control.
 
Actually, most VB'ers will create a single form, and then create instances of that form over and over, rather than having the same form as different names in different places. I understand the reason you are probably doing this is to save time....both forms are similar, so let's copy one and edit it. But there is alot you can do with a form in VB, including adding and moving controls, change and resize labels, etc.

Another approach to what you wanted to do, basically the same as vamp's approach from another direction - go to Windows Explorer, find your project file, and copy the form file(s), giving them new file names. Then open your project, add the new form to your project, and change it's project name when it gets there. It's basically the same thing, just a little more intuitive...

 
It won't let you open the second form if you change the name in Explorer, because when you try to add the second form to the project, VB will complain that you already have that form in the project.

It checks the form name in the *properties*, not the name of the file. So therefore it won't let you add the form to the project.

You would have to remove your first form from the project, add the second ( copied ) form into the project. Open it's properties and change it's form name, and then add the first form back into the project again. I think my way is a little better than that.

Plus, you would have to close the project because explorer won't let you rename a file that's in use...

Robert
 
Good point...you're exactly right....it won't let you open the second in my approach.

That's what I get for offering advise without making sure I'm right first.

So, in the words of the late Gilda Radner:

"Never mind"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top