How to create a new form instance using the name of the form as a String

后端 未结 3 447
遥遥无期
遥遥无期 2021-01-24 23:46

Code to create new form instance of a closed form using form name

I want to replace the long Select Case list with a variable.

Full code of modu

3条回答
  •  终归单人心
    2021-01-25 00:12

    Here's an ugly hack I found:

    DoCmd.SelectObject , , True
    DoCmd.RunCommand acCmdNewObjectForm
    

    The RunCommand step doesn't give you programmatic control of the object, you'll have to Dim a Form variable and Set using Forms.Item(). I usually close the form after DoCmd.RunCommand, then DoCmd.Rename with something useful (my users don't like Form1, Form2, etc.).

    Hope that helps.

提交回复
热议问题