• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Not the good Form_Activate

Hi,
  I have many forms in my pgm.
I have these three :
frmFacture
frmChoix
frmDblCli

Here is my problem:
In frmFacture, i call frmChoix and frmChoix call frmDblCli like this:

FrmChoix.Show 1
FrmDbLCli.Show 1

When i do F8 all works all right, but when i do F5 the Form_Activate of FrmDbLCli doesn't work it is Form_Activate of frmFacture that is  working, it doesn't make any sense.

Why and what to do?
Someone have an idea?
0
dosyl
Asked:
dosyl
  • 7
  • 3
  • 2
  • +1
1 Solution
 
rovermCommented:
Try this:

FrmChoix.Show 1
DoEvents
FrmDbLCli.Show 1
DoEvents

So that VB handles all well !



0
 
tkuppinenCommented:
If a form is hidden instead of unloaded then it will not have a load event.
0
 
dosylAuthor Commented:
roverm, itried DoEvents after to call Form like you writed and it doesn't work.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
tkuppinenCommented:
Do you hide or unload your forms?
0
 
dosylAuthor Commented:
tkuppinen , it doesn't work not more.
0
 
dosylAuthor Commented:
I hide frmChoix and frmDblCli.
0
 
rovermCommented:
Okay: this is what I tested:
in form1:

Private Sub Form_Load()
  Form2.Hide
  Form3.Hide
End Sub

Private Sub Command1_Click()
  Form2.Show 1
  Form3.Show 1
End Sub

where Command1 activates the other forms

in forms 2 and 3:

Private Sub Command1_Click()
  Me.Hide
End Sub

where command1 is a 'close form' button

This works fine !!!!!

Hope is does to when you try it !

;-) RoverM
0
 
dosylAuthor Commented:
My code is:
frmFacture->
Private Sub GrilleFact_CellButtonClick(Row As Long, Col As Long)
FrmChoix.Show 1
End Sub
frmChoix->
Private Sub ListChoix_DblClick()
Me.Hide
Set FrmChoix = Nothing
End Sub
frmDblCli->
Private Sub DBListCli_DblClick()
Me.Hide
Set FrmDbLCli = Nothing
End Sub
0
 
dosylAuthor Commented:
Hi, i found my error. It was because i hided my Form and i had others instructions after. Not logical.

I'll give the points to the first person that answer to this question :
When we hide a Form is it good to set the form to Nothing like this :
Me.Hide
Set FrmDbLCli = Nothing

0
 
freelnceCommented:
This is straight out of the VB On-line help:

When Show displays a modal form, no input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or unload a modal form (usually in response to some user action) before input to another form can occur. An MDIForm can't be modal.

Although other forms in your application are disabled when a modal form is displayed, other applications aren't.


As for your question on setting a hidden form to nothing: why would you want to do that?  If you set it to nothing without unloading the form then it does nothing with the form to free up any resources used by the form nor does it dereference the form itself.

In a new project module type the following example:


Public Sub Main()
   Form1.Show
   Form1.Hide
   Set Form1 = Nothing
   MsgBox ("Form Name = " & Form1.Name), vbOKOnly, "Form Name"
End Sub


When this  code runs you will still see the form name showing that the form is still referenced and it's used resources are intact.
0
 
dosylAuthor Commented:
Scuse, it is not clear for me. Do we put Set Form2=Nothing when we HIDE it; YES OR NO?
0
 
freelnceCommented:
freelnce changed the proposed answer to a comment
0
 
freelnceCommented:
Hello again dosyl,

No,  setting a form to nothing when you hide it is not necessary. It does not release any reosurces in use.  you only need to set the form to nothing if you are unloading it from memory:

UNLOAD FORM2
SET FORM2 = NOTHING
0
 
dosylAuthor Commented:
If someone  wants to see how i debug my pgm. for the form_Activate go to see: Please debug my pgm.(Question).
Now, freeInce thank's for your answer.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 7
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now