Greetings.
Bringing back an old topic.
But not dialog box this time around.
Same problem: passing variables between forms.
Issue: Form Load & Unload.
Previously, without proper testing of each and every cases, the output was like what I have expected, so I thought I would have no problem.
[1] Again, on the arrangement of Load Form1 vs. Unload Form2
Initially, I thought it doesn't matter but not until I found that it actually matters!
I realise that when I put Unload Form1 before Load Form2, I would not be able to
use the Public variables in Form1. And so, I placed Load Form2 before Unload
Form1.
The problem arises here when I did step [1]. I load Form3 from Form2. I deem that the error occurs because although in Form2, I have Load Form3 followed by Unload Form2, when Form3 is showed Form1 & Form2 is still loaded in the memory because everything goes in a sequence:
Load Form1
Load Form2
Load Form3
Unload Form3
Unload Form2
Unload Form1
Actually, the real scenario goes like this:
Forms: Form1, Form2, Form3.
Form3 can be loaded by Form1 and Form2.
Therefore, in Form3, I'd like to code for different activities for different form that loaded Form3. How can I achieve that?
I did ->
' Form3
Private Sub Form_Load()
If Form1.cmdGo Then
' Do something
ElseIf Form2.cmdGo Then
' Do something
End If
End Sub
However, I realised later that this is not right, because when I clicked on the navigation menu on the left hand side of the form to go to Form2, then Form3, it works fine. Continue with clicking on Form1, then Form3 -> output was not as expected, because, it doesn't go to the ElseIf all the time when at the beginning Form1.cmdGo is evaluated True. :-|
Sorry, I know it's a bit confusing there, but I hope someone would understand my problem.