Go Back   Access World Forums > Apps and Windows > VB.NET

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-07-2019, 07:00 PM   #1
Ryobi
Newly Registered User
 
Join Date: Mar 2012
Posts: 33
Thanks: 1
Thanked 1 Time in 1 Post
Ryobi is on a distinguished road
Calling a second form and closing the first form

I have search the web but I can not find how to open a second form and close the first form. I have try different codes (including trying to close it from the second form) but none seem to work. The code below will close the first and second form which is not what I need. I want the first form to close when the second form is opened. The code in the loading section of the first form.


Me.Hide()
Form2.Show()
Me.Close()


This is possible in vb.net ?

Ryobi is offline   Reply With Quote
Old 04-07-2019, 07:40 PM   #2
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,472
Thanks: 0
Thanked 575 Times in 571 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Calling a second form and closing the first form

Try explicitly naming the form to act on instead of the alias Me.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 04-08-2019, 02:21 AM   #3
Ryobi
Newly Registered User
 
Join Date: Mar 2012
Posts: 33
Thanks: 1
Thanked 1 Time in 1 Post
Ryobi is on a distinguished road
Re: Calling a second form and closing the first form

I have also tried that but I get an error message stating that the form has been moved. Basically it does not work.

Ryobi is offline   Reply With Quote
Old 04-08-2019, 02:36 AM   #4
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,472
Thanks: 0
Thanked 575 Times in 571 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Calling a second form and closing the first form

A tutorial I looked at showed use of Show and Hide. Unfortunately, I am not familiar enough with vb.net to advise further.

Unless you really mean to use VBA?
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 04-08-2019, 06:52 AM   #5
Ryobi
Newly Registered User
 
Join Date: Mar 2012
Posts: 33
Thanks: 1
Thanked 1 Time in 1 Post
Ryobi is on a distinguished road
Re: Calling a second form and closing the first form

I am using Vb.net. Thank you for trying.
Ryobi is offline   Reply With Quote
Old 04-08-2019, 03:12 PM   #6
Ryobi
Newly Registered User
 
Join Date: Mar 2012
Posts: 33
Thanks: 1
Thanked 1 Time in 1 Post
Ryobi is on a distinguished road
Smile Re: Calling a second form and closing the first form

I have the found the solution. It is to change the following setting:
"Project" menu -> 'YourApp' Properties... -> Application Tab
find : "Shutdown Mode"
Change from
"When startup form closes" --> "When last form closes"

I hope this helps other users.

Import note: If you are using more then one project you need change the setting on all projects.


Ryobi is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Parent form closing if Tab Control with Sub Form required fields are complete Rx_ Modules & VBA 8 02-14-2013 04:03 PM
Closing a form when closing a report Bryan Reports 3 05-07-2012 11:12 AM
Calling one form from inside the other than closing Griztkojr Forms 3 09-14-2011 08:00 PM
Opening a form based on the same table as the calling form gbat Forms 4 05-23-2006 03:54 AM
how to update a table bound to a data entry form without closing the form betsyr Modules & VBA 3 11-01-2001 06:09 PM




All times are GMT -8. The time now is 02:33 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World