views:

100

answers:

2

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

+1  A: 

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.

Tiberiu Ana
Thank you, thank you, ...I couldn't drag "multiple instances" out of my head for some reason. Perfect, simple, easy!
drachenstern
+2  A: 

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.

Tony Toews
If you can figure out a way to help folks like me correlate instance and "set x = new y" then I think you'ld be doing as much as could be done... ;-)Sure sure, it's like a dictionary definition, except for those words you can't remember how to spell...
drachenstern
That's where getting competent answers helps out. Part of the assistance folks who answer questions give is translating the question in the users terms to the products terms. And I had forgotten myself that the official term was instance. I had to look up the code in a system I built for a client.FWIW that system allows the user to sit in his pickup truck in an oil patch drilling site, create a daily field ticket with dozer and grader number, rate and hours, etc and then email the PDF to the customer right then and there via a cell card in the laptop.
Tony Toews