Confused II
04-03-2004, 02:21 PM
Hi!
Back again with another little problem!! The following bit of my programme asks the user for a name of the machine and number of items produced to update the corresponding 'number in stock' value. It all seems to working except it doesn't update the number value!! Once again I'll just say I'm new to programming and it's getting late so it's probably something really stupid!! :chuckle: Anyway, I'd appreciate any help!
Sub Add_Stock()
'Button 4- This adds new stock on to the database when new items are manufactured
'Read Data
For i = 1 To 100
machine(i) = Cells(i + 6, 3).Value
Next i
For i = 1 To 100
availability(i) = Cells(i + 6, 5).Value
Next i
'Ask user for the name of the machine
1 name2 = InputBox("What is the name of the machine?", "Name of Machine")
'Ask the user for the number of machines that have been manufacturee
number = InputBox("How many of " & name2 & " have been manufactured?", "Amount of New Stock")
matching_machine2 = "No"
For i = 1 To 99
If UCase(machine(i)) = UCase(name2) Then
matching_machine2 = "Yes"
'Check that the information is correct
check2 = MsgBox("Are you sure you want to add " & number & " of " & name2 & " to the database?", vbYesNoCancel, "Confirm Amendment")
If check2 = vbYes Then
temp7 = availability(i)
availability(i) = (temp7 + name)
'Output new 'number in stock' value
Cells(i + 6, 5).Value = availability(i)
Else
End
End If
Else
End If
Next i
'If there are no machines matching this name ask user to check if the spelling is correct
If matching_machine2 = "No" Then
MsgBox ("There are no machines in the database matching this name. Please ensure your spelling is correct!")
GoTo 1
Else
End If
End Sub
Thanks!
Lisa
Back again with another little problem!! The following bit of my programme asks the user for a name of the machine and number of items produced to update the corresponding 'number in stock' value. It all seems to working except it doesn't update the number value!! Once again I'll just say I'm new to programming and it's getting late so it's probably something really stupid!! :chuckle: Anyway, I'd appreciate any help!
Sub Add_Stock()
'Button 4- This adds new stock on to the database when new items are manufactured
'Read Data
For i = 1 To 100
machine(i) = Cells(i + 6, 3).Value
Next i
For i = 1 To 100
availability(i) = Cells(i + 6, 5).Value
Next i
'Ask user for the name of the machine
1 name2 = InputBox("What is the name of the machine?", "Name of Machine")
'Ask the user for the number of machines that have been manufacturee
number = InputBox("How many of " & name2 & " have been manufactured?", "Amount of New Stock")
matching_machine2 = "No"
For i = 1 To 99
If UCase(machine(i)) = UCase(name2) Then
matching_machine2 = "Yes"
'Check that the information is correct
check2 = MsgBox("Are you sure you want to add " & number & " of " & name2 & " to the database?", vbYesNoCancel, "Confirm Amendment")
If check2 = vbYes Then
temp7 = availability(i)
availability(i) = (temp7 + name)
'Output new 'number in stock' value
Cells(i + 6, 5).Value = availability(i)
Else
End
End If
Else
End If
Next i
'If there are no machines matching this name ask user to check if the spelling is correct
If matching_machine2 = "No" Then
MsgBox ("There are no machines in the database matching this name. Please ensure your spelling is correct!")
GoTo 1
Else
End If
End Sub
Thanks!
Lisa