Consulting

Results 1 to 6 of 6

Thread: Solved: Two instances of the same form?

  1. #1
    VBAX Regular
    Joined
    Jan 2007
    Location
    Dallas area
    Posts
    74
    Location

    Solved: Two instances of the same form?

    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 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!

    G.T.

  2. #2
    cant you just add the extra spaces/controls to the first form and then have a compare line option?

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    As a simple solution you could create a new instance of the original form....

    [VBA]
    Private Sub CommandButton1_Click()
    Dim form1 As New UserForm1
    form1.Show
    End Sub
    [/VBA]

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

  5. #5
    VBAX Regular
    Joined
    Jan 2007
    Location
    Dallas area
    Posts
    74
    Location
    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.)

    Thanks,

    G.T.

  6. #6
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    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.
    Regards,
    Rory

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •