Reputation: 16025
In a .net project, create two forms {Form1, Form2} and on each form create a basic button {Button1}
On [Form1] use this code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myform As New Form2
myform.Show()
End Sub
End Class
and on [Form2]:
Public Class Form2
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Close()
End Sub
End Class
So the question I'm trying to figure out is this: Does Microsoft Access permit this sort of thing? It's for an internal app, and I'm trying to figure out how to allow users to open more than one of a form at a time without having to resort to {copy form_a} {paste form_a as form_b} {detect if form_a is already running when they click the show_form button, and if so, start form_b, else, start form_a} {repeat ad-nauseum for form_c through form_infinity}
Ok, so if I can't do it in Access, that's fine, [begin rant] at this point I'm already trying to overcome some really bad UI decisions, as well as some bad table designs. The original developers had no idea what an intersection table is or why it could even remotely be useful. And this has around 8 years of live data in it, so I already have a fair bit of work to do to get things to work reasonably well.[end rant]
Thanks for listening, and thanks more for really good pointers to "here's the google search url link that I found that really gave me the best answer to your question" natch, as opposed to "RTFM n00b" ;-]
Additionally, this being my first time on stackoverflow, even though I'm trying to grok as much as I can from this fabulous UI, I think I've done something wrong on the formatting, so any pointers there would be appreciated as well...
Upvotes: 0
Views: 178
Reputation: 7882
Yes, you can open multiple copies of the same form.
' Used to open to the DailyFieldTicket form many times
Public frmDFT As Form
Set frmDFT = New Form_DailyFieldTicket
frmDFT.SetFocus
Notes:
- If the frmDFT is a variable defined in another form and you close the other form then this instance of the form abruptly closes.
- If there are spaces in the form name you need to replace them with _. Weirdnesses can happen if special characters are used in the forms name. I don't recall the details now. I now ensure these forms are named without any spaces or non alphanumeric characters just to on the safe side.
- I can't recall now what happens with OpenArgs. It may inherit the openargs of the first form which opened which can cause confusion.
- I vaguelly recall a problem with variables in use in the code but that was 3 or 5 years ago now so I misremember the details.
Thanks for asking. This gives me another page on my website or blog posting to create. Ahh, I see Allen Browne already has a decent page on this topic.
Upvotes: 2
Reputation: 3663
If all you want is to create multiple instances of the same form, there seem to be quite a few articles out there already discussing this.
Upvotes: 1