In a .net project, create two forms {Form1, Form2} and on each form create a basic button {Button1}
在.net项目中,创建两个表单{Form1,Form2}并在每个表单上创建一个基本按钮{Button1}
On [Form1] use this code:
Public Class Form1
在[Form1]上使用此代码: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
并在[Form2]上:公共类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}
所以我想弄清楚的问题是:Microsoft Access是否允许这类事情?这是一个内部应用程序,我试图弄清楚如何允许用户一次打开一个以上的表单,而不必诉诸{copy form_a} {paste form_a as form_b} {detect if form_a已经当他们点击show_form按钮时运行,如果是,则启动form_b,否则,启动form_a} {对form_c重复ad-nauseum到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]
好的,所以如果我不能在Access中这样做,那很好,[开始咆哮]此时我已经尝试克服一些非常糟糕的UI决策,以及一些糟糕的表设计。原始开发人员不知道交叉表是什么或为什么它甚至可以远程使用。这里有大约8年的实时数据,所以我已经做了相当多的工作来使事情变得更好。[结束咆哮]
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" ;-]
感谢您的倾听,感谢更多关于“这里是我发现的谷歌搜索网址链接的真正好的指示”,这真的给了我对你的问题的最佳答案“natch,而不是”RTFM n00b“; - ]
Additionally, this being my first time on *, 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...
另外,这是我第一次使用*,尽管我正试图尽可能多地从这个神奇的UI中删除,但我认为我在格式化方面做错了,所以任何指针都会受到赞赏。 ..
2 个解决方案
#1
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.
如果你想要的只是创建同一个表单的多个实例,那么似乎有很多文章已经在讨论这个问题。
#2
Yes, you can open multiple copies of the same form.
是的,您可以打开同一表格的多个副本。
' Used to open to the DailyFieldTicket form many times
'用于多次打开DailyFieldTicket表单
Public frmDFT As Form
公共frmDFT作为表格
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.
注意: - 如果frmDFT是以另一种形式定义的变量而您关闭另一个表单,则该表单实例会突然关闭。 - 如果表单名称中有空格,则需要用_替换它们。如果在表单名称中使用特殊字符,则会发生奇怪现象。我现在不记得细节了。我现在确保这些表单的名称没有任何空格或非字母数字字符只是为了安全起见。 - 我现在不记得OpenArgs会发生什么。它可能会继承打开的第一个形式的openargs,这会导致混乱。 - 我想回忆一下代码中使用的变量的问题,但现在是3年或5年前,所以我记错了细节。
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.
谢谢你的询问。这给了我在我的网站上的另一个页面或创建的博客帖子。啊,我看到艾伦布朗已经在这个话题上有一个不错的页面。
#1
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.
如果你想要的只是创建同一个表单的多个实例,那么似乎有很多文章已经在讨论这个问题。
#2
Yes, you can open multiple copies of the same form.
是的,您可以打开同一表格的多个副本。
' Used to open to the DailyFieldTicket form many times
'用于多次打开DailyFieldTicket表单
Public frmDFT As Form
公共frmDFT作为表格
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.
注意: - 如果frmDFT是以另一种形式定义的变量而您关闭另一个表单,则该表单实例会突然关闭。 - 如果表单名称中有空格,则需要用_替换它们。如果在表单名称中使用特殊字符,则会发生奇怪现象。我现在不记得细节了。我现在确保这些表单的名称没有任何空格或非字母数字字符只是为了安全起见。 - 我现在不记得OpenArgs会发生什么。它可能会继承打开的第一个形式的openargs,这会导致混乱。 - 我想回忆一下代码中使用的变量的问题,但现在是3年或5年前,所以我记错了细节。
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.
谢谢你的询问。这给了我在我的网站上的另一个页面或创建的博客帖子。啊,我看到艾伦布朗已经在这个话题上有一个不错的页面。