I have a code for inventory controls as follows. Private Sub CommandButton1_Clic
ID: 3696240 • Letter: I
Question
I have a code for inventory controls as follows.
Private Sub CommandButton1_Click()
Dim FindPartNo As String
Dim partNoRng As Range
FindPartNo = TextBox1.Value
Dim Quanity As Integer
Quanity = MsgBox("Is the data correct for the part(s) you used?" & vbNewLine & "Part Number" & vbNewLine & TextBox1.Value & vbNewLine & "Part Description" & vbNewLine & Value3 & vbNewLine & "Quanity" & vbNewLine & TextBox2.Value, vbYesNo, "Report")
If Quanity = vbNo Then Exit Sub
If Trim(FindPartNo) <> "" Then
With Sheets("Sheet1").Range("C:C") 'select the entire sheet
Set partNoRng = .Find(What:=FindPartNo, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not partNoRng Is Nothing Then
'locate the part number in the sheet
Application.Goto partNoRng, True
'address of the part number
Add = partNoRng.Address
'quantity of the part number
Value = Cells(partNoRng.Row, partNoRng.Column - 2)
'new quantity =quantity in sheet-user input quantity
Cells(partNoRng.Row, partNoRng.Column - 2).Value = Value - TextBox2.Value
Value = Cells(partNoRng.Row, partNoRng.Column - 2)
'cost of the user input quanity
Value2 = Cells(partNoRng.Row + 1, partNoRng.Column) * TextBox2.Value
'Description of part for report
Value3 = Cells(partNoRng.Row + 1, partNoRng.Column)
'display cost quantity
MsgBox "Cost of Parts Used is " & Round(Value2, [2])
Else
MsgBox "Part Number is not Found"
End If
End With
End If
End Sub
On the fifth line I have a msgbox which appears and tells the user what they have input into the system checking if it is okay. One part of the lines is the description of the parts which is in the excel file. I try to use Value3 which I make that cell later in the program near the bottom. Is it too late in the program for it to recognize it or do I need a different thing ( I tried making it string2).
Thanks
Explanation / Answer
yes, because the value of quantity is used for further execution of the program whereas the value of quantity is calculated by using the value3 which will be computed based on the value of quantity hence there will be a deadlock situation occur......
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.