Mike,
demonstrating the problem is fairly easy. here are the steps for setting up the same data:
1) add a 'Related Purchase Order' note type to Sales Orders.
2) in S/O Custom Menu Clicked replace the end of the sample script with this bit of code:
- Code: Select all
ElseIf MenuIndex = 3 Then
Set SO = SalesOrderObject
For Each note In SO.Notes
If note.NoteTypeKey = "kAA6D045C-9753-49B1-800A-835BB6216279" Then
'related PO
PurchaseOrderID = Trim(GetPOrderID(SO.database, note.NoteText))
If PurchaseOrderID <> "" Then
' MsgBox PurchaseOrderID
MDIParentObject.DrillDownByFormNumber PurchaseOrderID, 400
End If
Exit For
End If
Next
End If
End Sub
Function GetPOrderID(database, poNumber)
GetPOrderID = ""
With database
Dim SQL
Dim ReadHandle
ReadHandle = CInt(.StatementOpen(.ConnectionRead1, False, "", 1))
SQL = "SELECT OrderID FROM PO_Main WHERE OrderNo=" & database.FormatChar(poNumber)
If .ExecuteSelect(CInt(ReadHandle), CStr(SQL)) <> 0 Then
.BindMem CInt(ReadHandle), CInt(1), vbString
If .FetchRow(CInt(ReadHandle)) = True Then
GetPOrderID = CStr(.GetData(CInt(ReadHandle), CInt(1)))
End If
End If
.StatementRenew CInt(ReadHandle)
End With
End Function
(You will need to replace the GUID for the note type with the relevant UID out of the database)
3) (optional, but recommended) in Form Loaded breakout, change the label for menu item 3 to say 'Open Related Sales Order'.
4) Pick any Purchase Order other than the last one on the P/O form (I used 100339 for my test). Not really important for the purposes of this test, but if like me you like test data to more-or-less make sense, you may want to make a note of a part number on the order.
5) Create a new Sales Order, and in the Notes Tab, add a new 'Related Purchase Order' note, and put the P/O number in the note text.
6) Save the order.
Once the data is there test as follows:
1) Make sure all instances of P/O form are closed.
2) Open the Sales Order you just created.
3) pick 'Open Related Purchase Order' from the Record menu. It will open the P/O specified.
4) While still in Purchase Orders. Move to last (or first) record. Well any record other than the one you specificed in the S/O.
5) Leave P/O window open and go back to S/O and try the menu item again. It will go to the P/O screen, but not drill to the specified P/O ID.