developerWorks  >  Lotus  >  Forums & community  >  IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)



Subject Code
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim lookupkey As String
Dim SKUkey As String
Dim QTYkey As String
Dim invcount As Long
Dim n As Integer

Set uidoc = ws.currentdocument
Set db = session.CurrentDatabase
Set view = db.GetView("Inventory")
' Individual Item section
For n = 1 To 14
SKUkey = "Item_Partnumber" & n
QTYkey = "QTY" & n
On Error Goto Kit
lookupkey = uidoc.FieldGetText(SKUkey)
Set doc = view.GetDocumentByKey(lookupkey, True)
invcount = doc.Item_InStock(0)
invcount = invcount - Clng(uidoc.FieldGetText(QTYkey))
doc.Item_InStock = invcount
Call doc.Save(True, True)
Next
The above section works exactly as intended. The problem is called out below.
Kit:
For n = 1 To 14
SKUkey = "Kit_Partnumber" & n
QTYkey = "KitQTY" & n
On Error Goto Done
lookupkey = uidoc.FieldGetText(SKUkey)
Set doc = view.GetDocumentByKey(lookupkey, True)


The line below is where I get the error. I expect the error when doc ="" but the problem is it wont go to the Done label then exit the sub. However in the first loop it works as desired.
invcount = doc.Item_InStock(0)
invcount = invcount - Clng(uidoc.FieldGetText(QTYkey))
doc.Item_InStock = invcount
Call doc.Save(True, True)
Next
Bail:
Print "Posted All Items"
Resume Next
Done:
Print "Posted All Items"
Resume Next
End Sub

Note: I added the Done tag in case reusing Bail was the problem but it made no difference.

Feedback response number WEBB8TR8F5 created by Rory Fansler on 05/21/2013

Go back