Consulting

Results 1 to 7 of 7

Thread: Solved: Userform to Userform

  1. #1

    Solved: Userform to Userform

    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!
    Last edited by Learner123; 11-18-2010 at 11:21 AM. Reason: Attachment was initially omitted

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    So what do you want it to do that it doesn't do now?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    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.

  4. #4
    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:

    [VBA]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
    [/VBA]

  5. #5
    Hi all - Please note that the above posting has also been posted in the below link. Issue still persists

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

  6. #6
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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.
    [vba]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[/vba]

    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.

  7. #7
    Thanks for your help Kenneth!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •