Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:18:32+00:00 2026-06-05T15:18:32+00:00

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

  • 0

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 module


In Access 2010 I have a VBA function that opens a new instance of a form when given a string containing the form’s name. By adding a form variable “frm” to a collection:

mcolFormInstances.Add Item:=frm, Key:=CStr(frm.Hwnd)

The only way I can figure out to open “frm” is with a Select Case statement that I’ve manually entered.

Select Case strFormName
    Case "frmCustomer"
        Set frm = New Form_frmCustomer
    Case "frmProduct"
        Set frm = New Form_frmProduct        
    ... etc ... !
End Select

I want it to do it automatically, somewhat like this (although this doesn’t work):

Set frm = New Eval("Form_" & strFormName)

Or through some code:

For Each obj In CurrentProject.AllForms 'or AllModules, neither work
    If obj.Name = strFormName Then
        Set FormObject = obj.AccessClassObject 'or something
    End If
Next

Set frm = New FormObject

I just want to avoid listing out every single form in my project and having to keep the list updated as new forms are added.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:18:34+00:00Added an answer on June 5, 2026 at 3:18 pm

    I’ve also done some testing of my own and some reading online about this. As near as I can tell, it isn’t possible to create a new form object and set it to an instance of an existing form using a string that represents the name of that form without using DoCmd.OpenForm.

    In other words, unless someone else can prove me wrong, what you are trying to do cannot be done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to symfony. I have created a registration form using the code:
I am using following code to create new wifi access point and to connect
I want code to run whenever I create a new object. For example, see
I am trying to reuse shape data to dynamically create new shapes in code.
Hola check this code. var watch = new Stopwatch(); watch.Start(); var request = HttpWebRequest.Create(new
I am trying to create a new Element in my javascript code and append
I have this code to create an ATOM feed Dim xmlResult As New StringBuilder
I'm trying to create a new log file every hour with the following code
I am trying to create a new db called testDB2, below is my code.
Lets say that I'm trying to create a new process with the following code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.