View Full Version : [SOLVED:] how can do this: if any userform closed(x) then mainform.show
kofatoto
09-08-2017, 11:39 PM
hello
excuse me for my bad English language
i have main form and 3 an other forms
i want if i closed any form by (x) in title bar , the main form show automatically
any help for this
thanks
mdmackillop
09-09-2017, 12:34 AM
Include in other forms
Private Sub UserForm_Terminate()
UserForm1.Show
End Sub
Bob Phillips
09-09-2017, 01:27 AM
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
With Me
If CloseMode = vbFormControlMenu Then
Cancel = True
MainForm.Show
Me.Hide
End If
End With
End Sub
kofatoto
09-09-2017, 01:56 AM
thanks mdmackillop (http://www.vbaexpress.com/forum/member.php?87-mdmackillop)
but if i try again, data not loaded and (x) button disabled
can you resolve it
thanks xld (http://www.vbaexpress.com/forum/member.php?2139-xld)
main form show but the userform not hide
can you resolve it
mdmackillop
09-09-2017, 02:09 AM
Please post a workbook so we can see all your code
kofatoto
09-09-2017, 03:15 AM
my file
https://app.box.com/s/vaxi3ilcnutbn31c4f66uomuweiuezjw
Bob Phillips
09-09-2017, 03:18 AM
add this to the main form code
Private Sub UserForm_Activate()
Dim frm As UserForm
For Each frm In UserForms
If Not frm Is Me Then Unload frm
Next frm
End Sub
kofatoto
09-09-2017, 08:10 AM
thanks xld
but userform1 not unload when i closed it
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
(http://www.vbaexpress.com/forum/member.php?2139-xld)
my file
https://app.box.com/s/vaxi3ilcnutbn31c4f66uomuweiuezjw
I can't open that link
You can upload files here by Going Advanced, and at the bottom, use Manage Attachments
But, try this in three other forms.
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
MainForm.Show
End Sub
kofatoto
09-09-2017, 11:34 AM
new link
http://www.mediafire.com/file/vn112iij08s7qyq/kofa.rar
Leith Ross
09-09-2017, 06:50 PM
Hello kofatoto,
This version has been modified to control the closing and showing of the UserForms through the Query_Close and Terminate events. There are 2 public variables in Module1 that these events use along with a new Sub called CloseForms.
kofa ver 1.xlsm (https://www.mediafire.com/file/g2ijls8b16wpg52/kofa%20ver%201.xlsm)
kofatoto
09-09-2017, 11:32 PM
thanks leith ross
work fine but developer tab disabled and i can not edit any file
please help me
Bob Phillips
09-10-2017, 02:48 AM
YOu keep making odd statements, you told Mac that the x button was disabled, now you are saying that the developer tab is disabled, when the people aren't touching these. What exactly do you mean?
kofatoto
09-10-2017, 03:18 AM
excuse me
before
i can edit my file but when i downloaded kofa ver 1.xlsm (https://www.mediafire.com/file/g2ijls8b16wpg52/kofa%20ver%201.xlsm)
it is ok and my problem solved but when i want to editing any things , i cant because developer tab disabled
why ?
i dont know
Leith Ross
09-10-2017, 10:28 AM
Hello kofatoto,
I downloaded the file and was able to open the Developer Tab with no issues. Do you have this same issue with any other macro enabled workbooks downloaded from the internet?
kofatoto
09-10-2017, 11:00 AM
hi leith ross
i am not able to open the Developer Tab and any tab when any userform show
my office is 2016
Leith Ross
09-10-2017, 12:06 PM
Hello kofatoto,
I built in a safeguard so you can view the application and the VBA editor. When your main UserForm "Form1" is displayed. double click on the UserForm. This will allow you to edit the code.
kofatoto
09-10-2017, 12:44 PM
thanks leith ross
now its work fine and i can edit my file
thanks again
my respect to all
Leith Ross
09-10-2017, 12:55 PM
Hello kofatoto,
You're welcome. If you run into any problems, let me know.
kofatoto
09-10-2017, 01:45 PM
thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.