PDA

View Full Version : Solved: Userform to Userform



Learner123
11-18-2010, 11:18 AM
Hi,

I am attempting to have userform1 initiate userform4 once a user clicks "next" on userform1. I have not had any luck looking this up in the forum. Can someone help?

I have posted a sample of my file.

Thanks in advance!

Bob Phillips
11-18-2010, 11:38 AM
So what do you want it to do that it doesn't do now?

Learner123
11-18-2010, 11:43 AM
I am trying to get the General Contractor data from the userform4 to populate into range "GCBudget" once "complete setup" is clicked.

I thought that the problem occured in the transfer from one userform to the other.

Learner123
11-23-2010, 07:24 AM
Hi again - I continue to have a problem with my code and was hoping someone can show me where my error lies. I would like the for the below code to be able to transition from one userform to the next userform and populate the excel sheet once "proceed" is clicked on the last userform. I believe I my code needs to be rearranged some how but not quite sure how.

Anyone up for a challenge?

Thanks a bunch!

Code:

Private Sub Cancel_Click()
Unload Me
End Sub
Private Sub NextForm_Click()
Dim RowCount As Long
Dim ctl As Control
If Me.TextBox1.Value = "" Then
MsgBox "Please Enter City and State.", vbExclamation, "NOT SURE WHY"
Me.TextBox1.SetFocus
Exit Sub
End If

If Me.TextBox2.Value = "" Then
MsgBox "Please Enter CREAS Region Data.", vbExclamation, "NOT SURE WHY"
Me.TextBox2.SetFocus
Exit Sub
End If
If Me.TextBox3.Value = "" Then
MsgBox "Please Enter Portfolio Management Data.", vbExclamation, "NOT SURE WHY"
Me.TextBox3.SetFocus
Exit Sub
End If

If Me.TextBox4.Value = "" Then
MsgBox "Please Enter Project Manager.", vbExclamation, "NOT SURE WHY"
Me.TextBox4.SetFocus
Exit Sub
End If

If Me.TextBox5.Value = "" Then
MsgBox "Please Enter RSF/M2 Data.", vbExclamation, "NOT SURE WHY"
Me.TextBox5.SetFocus
Exit Sub
End If

If Me.TextBox6.Value = "" Then
MsgBox "Please Enter Funding %.", vbExclamation, "NOT SURE WHY"
Me.TextBox6.SetFocus
Exit Sub
End If

RowCount = Worksheets("Detail").Range("d16").CurrentRegion.Rows.Count
With Worksheets("Detail").Range("d16")
.Offset(0, -1).Value = Me.TextBox1.Value
.Offset(1, 0).Value = Me.TextBox2.Value
.Offset(2, 0).Value = Me.TextBox3.Value
.Offset(3, 0).Value = Me.TextBox4.Value
.Offset(4, 0).Value = Me.TextBox5.Value
.Offset(5, 0).Value = Me.TextBox6.Value

End With

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
End If
Next ctl
'when user clicks next, userform1 executes and then unloads
Unload Me

' userform4 automatically loads after clicking next
Load UserForm4
UserForm4.Show

End Sub
Private Sub Proceed_Click()
Dim RowCount As Long
Dim ctl As Control
If Me.TextBox7.Value = "" Then
MsgBox "Please approved General Contractor budget amount.", vbExclamation, "NOT SURE WHY"
Me.TextBox7.SetFocus
Exit Sub
End If


RowCount = Worksheets("Detail").Range("GCBudget").CurrentRegion.Rows.Count
With Worksheets("Detail").Range("GCBudget")
.Offset(0, 0).Value = Me.TextBox7.Value
End With
End Sub

Learner123
11-24-2010, 11:26 AM
Hi all - Please note that the above posting has also been posted in the below link. Issue still persists :banghead: :banghead: :banghead:

http://www.ozgrid.com/forum/showthread.php?t=148323

Kenneth Hobs
11-24-2010, 12:13 PM
Why do you need Load if you don't put any values into the userform before Show?

Use the userform's Hide property to retain the values and Unload them at the end.

For the userform4, this code should get you going but you are already doing something similar in userform1.
Private Sub Proceed_Click()
Dim r As Range
Set r = Worksheets("Detail")
With r
.Range("A28").End(xlUp).offset(1).Value = TextBox7.Value
.Range("A34").End(xlUp).offset(1).Value = TextBox9.Value
'etc.
End With
Set r = Nothing
End Sub

I recommend using a naming convention for your textbox controls to make it easier to see what is what. e.g. Change TextBox7 on userform4 to tbGeneralContractor.

Learner123
11-30-2010, 11:59 AM
Thanks for your help Kenneth!