How call On Load Event for a Form included in a Main Form ? (1 Viewer)

corentin

New member
Local time
Tomorrow, 00:14
Joined
Jan 22, 2020
Messages
12
Hello dear users,

In order to finish my "MRP" project, I need your help. I have a mainfrom called Main_Form and an other form called Stock_Management. What I want is simple : display the Stock_Management form (when I click on a button) in the subform window of the mainform (that is working) but I want ALSO that the On_Load Event of Stock_Management form run when it displays it.

If you have idea, any help would be welcomed !

Thank you,

Corentin
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:14
Joined
May 21, 2018
Messages
8,529
I would have assumed it would run after setting the Sourceobject of the subform control. However, in general to run a procedure in a subform you can call it like:
me.subformcontrol.form.Some_Procedure_Name
 

corentin

New member
Local time
Tomorrow, 00:14
Joined
Jan 22, 2020
Messages
12
I would have assumed it would run after setting the Sourceobject of the subform control. However, in general to run a procedure in a subform you can call it like:
me.subformcontrol.form.Some_Procedure_Name

Thank you for your help bu I didn't understand the syntax well. What does subformcontrol means ? form is the current form where the subform is included ?

I show you my vba code that displays well the form "Add_New_Part" from the main form called "Main_Form" but doesn't load it as I doubled click on its name in the forms bar ...
 

Attachments

  • Capture.PNG
    Capture.PNG
    37.4 KB · Views: 127

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:14
Joined
May 21, 2018
Messages
8,529
Form_View is the name of the subform control. To return the form inside the Form_View you use the word .Form. The subform control and the form inside are often called subforms but they are two different things. I call the thing inside the subform and the container the subformcontrol
me.Form_View.Form.YourProcedureName The name of the procedure is actually Form_Load
me.Form_View.Form.YourProcedureName.Form_Load
 

corentin

New member
Local time
Tomorrow, 00:14
Joined
Jan 22, 2020
Messages
12
Form_View is the name of the subform control. To return the form inside the Form_View you use the word .Form. The subform control and the form inside are often called subforms but they are two different things. I call the thing inside the subform and the container the subformcontrol
me.Form_View.Form.YourProcedureName The name of the procedure is actually Form_Load
me.Form_View.Form.YourProcedureName.Form_Load

Ok thanks for this lighting explanation but I am beginner in Acess and I don't know now what you meant by "YourProcedureName" ... Here is the code that I did and doesn't work ...

Private Sub Part_Click()
Me.Form_View.SourceObject = "Add_New_Part"
Me.Form_View.Form.Form_Load
End Sub

Well maybe it is impossible to do in Access what I want ? I mean not to display a form in a mainform BUT load a form in a mainform (on the same window). Thank you a lot to help me.

Corentin
 

Attachments

  • Capture.PNG
    Capture.PNG
    8.3 KB · Views: 96
  • Capture2.PNG
    Capture2.PNG
    4.8 KB · Views: 90

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:14
Joined
May 21, 2018
Messages
8,529
I mean not to display a form in a mainform BUT load a form in a mainform (on the same window).
I am not sure what you mean by this. You are displaying a form within a subform control named Form_View. Not sure the difference between displaying and loading. Can you explain more. Your code looks correct to me. What is the code in the Form_Load() procedure?
 

corentin

New member
Local time
Tomorrow, 00:14
Joined
Jan 22, 2020
Messages
12
Sorry guys I found the solution of the problem ! I just have to modify the On_Load Event by refering it to my main form !!!!
 

Users who are viewing this thread

Top Bottom