fl78
asked on
vb stuff.... load form 2 from form 1
I have a vb project which consists of 2 forms. And my startup object is form 1. In my form 1, I plan to create a command button to load form 2 and unload form 1 when I click on the button. Can anybody here provide me the source code in order to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
declare rs in bas module.
ASKER
Form 1:
Private Sub cmdCMR_Click()
rs.Close
Unload Form1
Load Form2
Form2.Show
End Sub
Form 2:
Private Sub cmdGoToIMR1_Click()
rs.Close
Unload Form2
Load Form1
Form1.Show
End Sub
And if I use Unload instead of Hide.... there is no error. But, I might lose my data.....
Private Sub cmdCMR_Click()
rs.Close
Unload Form1
Load Form2
Form2.Show
End Sub
Form 2:
Private Sub cmdGoToIMR1_Click()
rs.Close
Unload Form2
Load Form1
Form1.Show
End Sub
And if I use Unload instead of Hide.... there is no error. But, I might lose my data.....
ASKER
ashunigam,
Could you show me how to do this... as i am just a beginner .... thanks....
Could you show me how to do this... as i am just a beginner .... thanks....
select add Module. This will add a bas module to your project. Now public variables declared here could be accessed globally and will cease to exist when application is terminated. So you won't lose data as unloading will not clean the variable.
For this you don't need to do any other changes than moving the declared to a module.
Hope it helps.
For this you don't need to do any other changes than moving the declared to a module.
Hope it helps.
ASKER
Private Sub cmdCMR_Click()
rs.Close
Form1.Hide
Load Form2
Form2.Show
End Sub
Form 2:
Private Sub cmdGoToIMR1_Click()
rs.Close
Form2.Hide
Load Form1
Form1.Show
End Sub
when I click the button back and forth... there is run time error '3420
object invalid or no longer set... and the debug arrow point to rs.close..... Pls advice.