Store Value from one form and then ask for a multiplier in second form

Again, I am horrible in Excel VBA so please take it easy on me.

What I am trying to do is store a numerical value of a barcode in UserForm7.Textbox1 using the first set of code then have the application wait 2 seconds and then open UserForm8 and store an integer that is hand-typed  in Userform8.Texbox1.  Then on button click it looks up the barcode value in the sheet, shifts one cell to the right, and adds the muliple from UserForm8.TextBox1 to the number that already exists in that cell.  Running into all kinds of issues but the first was I had UserForm7 and UserForm8 showing up at the same time.

I can certainly add more code or upload the file if it helps you help me.

Private Sub TextBox1_Change()

If Not IsActive And TextBox1.Text <> "" Then
  
  IsActive = True
  Application.OnTime Now + TimeValue("00:00:03"), "UserForm7.Hide"
  UserForm8.Show
End If

End Sub



Private Sub UserForm_Initialize()


IsActive = False
TextBox1.SetFocus
  
End Sub

Open in new window


Private Sub btn_MultipleAdd_Click()
Worksheets("Main").Unprotect
Dim TargetCell As Range
Dim TextBox1 As Integer
If WorksheetFunction.CountIf(Sheets("Main").Columns(4), TextBox1.Value) = 1 Then
    Set TargetCell = Sheets("Main").Columns(4).Find(TextBox1.Value, , xlValues, xlWhole).Offset(0, 1)
    TargetCell.Value = TargetCell.Value + TextBox1
    TextBox1.Value = ""
    TextBox1.SetFocus
Else
    MsgBox "Item Not Found"
End If
Worksheets("Main").Protect
End Sub

Open in new window

rmc71291Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
It would be simpler to have one UserForm, but use a MultiPage control.

if not then you need to declare a Global variable that will store the bar code
0
rmc71291Author Commented:
Just to close out the topic, I was able to do this on my own but using a single form.  I'm pretty proud of myself because this is the first time I've really written code myself.  Of course pieces of it are scavenged from others but I made it all work myself.  Probably not much to you guys but I fell like a big boy now.

Private Sub UserForm_Initialize()
  
  IsActive = False
  TextBox1.SetFocus
  
End Sub

Private Sub TextBox1_Change()

If Not IsActive And TextBox1.Text <> "" Then
  
  IsActive = True
  Application.OnTime Now + TimeValue("00:00:03"), "Module13.Multiplier"
  
End If

End Sub

Open in new window


Sub Multiplier()
UserForm7.TextBox2.SetFocus
End Sub

Open in new window


Private Sub MultiAdd_Click()
Worksheets("Main").Unprotect
Dim TargetCell As Range
If WorksheetFunction.CountIf(Sheets("Main").Columns(4), TextBox1.Value) = 1 Then
    Set TargetCell = Sheets("Main").Columns(4).Find(TextBox1.Value, , xlValues, xlWhole).Offset(0, 1)
    TargetCell.Value = TargetCell.Value + TextBox2.Value
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox1.SetFocus
Else
    MsgBox "Item Not Found"
End If
Worksheets("Main").Protect

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rmc71291Author Commented:
Other responses did not quite answer as asked but offered reasonable alternatives.  In the end, I chose a different route than the original question or the alternate solutions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.