View Full Version : Solved: Two instances of the same form?

07-24-2007, 10:48 PM
I have a form that shows some information about a particular line in a large batch of data... you enter the line #, and it shows you various aspects of that line.

There are times I'd like to bring up a second copy of that same form so I can enter another line # in the second form, then compare the two lines by looking at both instances of the form. Is that (a) possible, and (b) a reasonable thing to do? Or will I end up :banghead: and wish I'd just made frmShowLineA and frmShowLineB to accomplish the same end? Seems like I've seen an explanation of how to do this someplace, but I couldn't seem to find it now.

Many thanks!


07-25-2007, 12:00 AM
cant you just add the extra spaces/controls to the first form and then have a compare line option?

Bob Phillips
07-25-2007, 01:10 AM
It is possible, but it seems to me better to allow that option on the one form. You could add a multipage to keep the size down if that is a problem.

07-25-2007, 01:11 AM
As a simple solution you could create a new instance of the original form....

Private Sub CommandButton1_Click()
Dim form1 As New UserForm1
End Sub

Not the most elegant solution but should work ok....

07-25-2007, 07:35 AM
Thanks, daniel & xld. Ended up going that route, mainly because it will be easier to add the other output on the form later to show some of the most obvious comparisons between whatever is in the top 2 outputs.

Thanks also c19+; for where I'm at on this project, that answer won't work as well, although there are a couple of other places I may try something like that... if nothing else just to play around with seeing how it works. That was, I think, what I'd seen somewhere before that I had vaguely in mind when I asked the question. (If anyone has comments on the strengths/weaknesses of c19+ 's approach, I'd be interested in seeing them.)



07-25-2007, 07:40 AM
My personal preference would be C19's approach. It's more flexible, as you can open as many copies as you want, saves you duplicating the same controls/functionality across multiple tabs, and easier to maintain as you only make changes in one place.
On the other hand, if you can guarantee you will only ever need to compare two items, you can build in more specific functionality to a two tab form.