Question Windows Navigation

roney

Member
Joined
Feb 12, 2009
Messages
7
Programming Experience
Beginner
hi,

I have got 2 forms ----- form1 and form2

i wanted to navigate from form1 to form2. and then close form1

i did the following code.

-sub form1 _ page load

dim form as new form2
form.show()
me.close

-end sub

i also tried -- form1.close() and form1.dispose() but all in vain

Problem is that my form1 is not getting closed


Please Help.
 
You can't close a form in its Load event handler. It hasn't even been opened at that point so it can't be closed. Why would you want to do that anyway? If you don't want Form1 open then why are you opening it at all? Why not make Form2 the startup form?
 
hi jmcilhinney

The form1 is the login form, the form2 is employee resgister form.

those who login and have access only can go to the next form to access the data. thats why i need the first form.
 
In that case you wouldn't show Form2 from the Load event handler of Form1 because, as I said, Form1 hasn't even been displayed at that point. You'd want to show Form2 from the Click event handler of your Login or OK button, if and only if the login was successful.

That said, even that is not the right way to go. You shouldn't be using the login form as the startup form. The application's main form should be the startup form and you should display the login form from the application's Startup event handler. Check out this example.
 
I tried that also but it didn't help .
That comment is of no value. If you followed those instructions then it would work, so you've obviously done something wrong or, at least different. I can't guess what that might be so I can't provide any assistance. If you want help then you need to provide information. A FULL and CLEAR description of EXACTLY what you did and EXACTLY what happened would be a good start.
 
Back
Top