Opening a Userform while within a Userform

cruisinkrissy

New Member
Joined
Aug 10, 2017
Messages
3
I am currently using Excel to auto save into certain files on my computer. I have an input box that asks for the job description and the phase the job is in (using a pull down list). I am trying to make sure that no one can save the worksheet without selecting a job phase, in attempt to do this I created another Userform that I labeled phase that I would like to show up when someone tries to save the worksheet without selecting said phase. The problem is that I can't figure out how to call the 2nd userform to show itself while in the original userform. I hope this makes sense and someone can help. I am willing to show the code I am using in my main userform to help me further.

thanks in advance
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This is the most basic way of doing this, so if you need anything more then let us know:

In this example I have 2 userforms - Userform1 has a combobox and a button (pretend its the save button!)

The code for the button checks if the combobox is empty, if it is then it will show userform2, otherwise it will just carry on with the rest of the code.

Hope this makes sense and points you in the right direction

Code:
Private Sub CommandButton1_Click()
If Me.ComboBox1 = vbNullString Then
UserForm2.Show
Else
[COLOR="#008000"]'What ever you want to happen![/COLOR]
End If
End Sub
 
Upvote 0
Thanks! I am attaching my code because I am getting an error message saying that I'm missing and End If when I apply that code to my existing code

It is a long code, hopefully you can interpret it. I am not 100% "code" savy but I can help to explain when needed. For the Else statement, if it can take the selection for userform 2 (Phase ) and apply it to userform 1 (Save_As) that would be ideal but i'm not sure how that would look in code.




Private Sub Save_File_Click()


Application.ScreenUpdating = False


Dim FileName As String
Dim Job_Number As String
Dim Parent_Folder As String
Dim Search As String
Dim Job_Folder As String
Dim Job_Year As String
Dim Full_Path As String
Dim Partial_Path As String
Dim Phase As String
Dim Description As String


Phase = Me.Project_Phase.Value
Description = Me.File_Description.Value


Private Sub CommandButton1_Click()
If Me.Save_As = vbNullString Then
Phase.Show
End If
End Sub


Sheets("Clip Connection").Select
Job_Number = Range("K1")
Job_Year = Left(Job_Number, 2)


If Job_Year = "" Then
Job_Number = InputBox("Insert project number")
Job_Year = Left(Job_Number, 2)
'Unload Me
Sheets("Clip Connection").Select
Range("k1").Value = Job_Number
End If


If Job_Year = 16 Then
Parent_Folder = "K:\Tech_Service_2016"
ElseIf Job_Year = 17 Then
Parent_Folder = "K:\Tech_Service_2017"
ElseIf Job_Year = 18 Then
Parent_Folder = "K:\Tech_Service_2018"
ElseIf Job_Year = 19 Then
Parent_Folder = "K:\Tech_Service_2019"
ElseIf Job_Year = 20 Then
Parent_Folder = "K:\Tech_Service_2020"
ElseIf Job_Year = 21 Then
Parent_Folder = "K:\Tech_Service_2021"
ElseIf Job_Year = 22 Then
Parent_Folder = "K:\Tech_Service_2022"
Else
MsgBox ("Cannot find job folder in the directory")
Unload Me
Sheets("Clip Connection").Select
Exit Sub
End If


Search = Parent_Folder & Job_Number & "*"
Job_Folder = Dir(Search, vbDirectory)
FileName = Range("k1") & " Connection Design - Pullout (" & Description & ")"


If Phase = "Estimate" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Estimate"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Partial_Path & FileName & ".xlsm"
ElseIf Phase = "Approval A" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Approval A"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Approval A" & FileName & ".xlsm"
ElseIf Phase = "Approval B" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Approval B"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Approval B" & FileName & ".xlsm"
ElseIf Phase = "Approval C" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Approval C"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Approval C" & FileName & ".xlsm"
ElseIf Phase = "Approval D" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Approval D"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Approval D" & FileName & ".xlsm"
ElseIf Phase = "Construction 0" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 0"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 0" & FileName & ".xlsm"
ElseIf Phase = "Construction 1" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 1"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 1" & FileName & ".xlsm"
ElseIf Phase = "Construction 2" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 2"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 2" & FileName & ".xlsm"
ElseIf Phase = "Construction 3" Then
Partial_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 3"
If Dir(Partial_Path, vbDirectory) = "" Then
MkDir (Partial_Path)
End If
Full_Path = Parent_Folder & Job_Folder & "\Engineering\Construction 3" & FileName & ".xlsm"
End If


With ws
Sheets("index").Select
Range("K2").Select
ActiveCell.Value = Me.File_Description.Value
End With


Sheets("Clip Connection").Select


ActiveWorkbook.SaveAs FileName:=Full_Path
Unload Me


End Sub


Private Sub UserForm_Click()


End Sub



thank you for all your help!!
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top