How to load multiple User forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wdecua
    New Member
    • Jan 2014
    • 1

    #1

    How to load multiple User forms

    I currently writing a program for my QA department where the user has to do the following
    Enter a part number in a Text Box (example part number ag782241)
    Hit “OK” on a Command Button
    The program then hides UserForm1 and then it will search for UserFormag78224 1
    It then shows the UserFormag78224 1
    I have about 500 different part numbers
    Right now I have my program to go directly to UserFormag78224 1
    Please help me were I’m a novice in VB
    _______________ _______________ _______________ _______________ _______________ __
    Code:
    Private Sub btnOK_Click()
     ' Check blanks
     If Trim(TextBox1.Text) <= "" Then
        MsgResp = MsgBox("You must enter PART NUMBER", vbYes, "Part Number")
        TextBox1.SetFocus
         Exit Sub
     End If
     UserForm1.Hide
     UserFormag782241.Show (page1)
    Last edited by Rabbit; Jan 28 '14, 08:35 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    The logic behind what you're doing should be something like this:

    Code:
    If textbox.text = "" then
    MsgBox("You must enter a part number", vbOKOnly, "Part Number")
    textbox1.setfocus
    else
    dim partNumberForm As New Form
    dim frm as Form
    
    partNumberForm.Text = "UserForm" + textbox1.text
    
    For Each frm In Forms
    If frm.text = textbox1.text then
    UserForm1.Hide
    partNumberForm.Show()
    End If
    Next
    The actual code may be wrong as I was only writing out the logic. Hope it helps!

    Comment

    • JosephTele
      New Member
      • Jan 2014
      • 3

      #3
      The logic given here seems absolutely perfect! I think you just implement it and your problem will be solved.

      Comment

      Working...