Control another form from the current form

jithb4u

New member
Local time
Today, 20:45
Joined
Aug 12, 2022
Messages
5
Sorry for my poor English as it is not my mother tongue.
I have a form named "Form1".
I created a command button in "Form1", to create a form with form wizard (DoCmd.RunCommand acCmdNewObjectForm) and saved it as "Form2".
My question is:
Is it possible to add some statements in "Form2 Load()" from "Form1".
 
I created a command button in "Form1", to create a form with form wizard (DoCmd.RunCommand acCmdNewObjectForm) and saved it as "Form2".
what are you trying to do?
you create the Form "normally", not by creating it from nowhere?
access can do that, but this is wrong.
build plan/blueprint of what you need. plan ahead.
and translate those plans into tables and forms/reports.
 
Agreed. It's normal to have a second form that you want to open from the first, and to even have some redesign at run time - change some text, hide some fields etc - but it's very unusual to need to create a new form. Why would you do that, rather than use an existing form?
 
Is it possible to add some statements in "Form2 Load()" from "Form1".
Yes, it is. Look at the Module object in the Access object library. It has methods to add code to your project; the CreateEventProc function may of special interest in this case.

However, I fully agree with the previous replies to your question. Unless you are developing some sort of wizard tool, it usually is a bad design idea to create new objects in your application at run time.
 
The biggest reason you don't want to dynamically create controls is that you have limits on the sizes of modules and limits on the number of modules and limits on the space that modules take up. If you are creating a form in a DB from code running in the same DB, you have code taking up space that should be used for solving your primary problem, not for building more objects in the user interface.

The more common approach is that you create your forms manually and if there is something you don't want to see or DO want to see, you control their visibility and position programmatically, you don't create or delete them. If you want specific permanent placement, you move things where you want them manually and then save them that way. Doing that, you have no ambiguity about where things will go.

Having said that, there is no particular barrier to creating your own wizard other than that using VBA, you are using an interpretive language rather than a compiled language and it won't be fast to do what you want. Oh, not terribly slow - but not as fast as a truly compiled wizard such as the ones supplied with Access.
 

Users who are viewing this thread

Back
Top Bottom