Yes, it is very useful snippet. I have a Command Button named SelectVisit in Patient Index File. When you press that it gives all the visit dates and Whatever date you select, it opens up the visit details.
Just in your case, it can list the OrderNumber and Date of the order and selecting that should open up that order. This will change from having ability to open up just the last order to any order including the last one. Instead of my "Physical" form, yours will be "SalesOrderForm".
I thought it would help with your application.
Following is my code:
var vRSHandle as int
var vTotalRecords as int
var vLoop as int
var vVisitDate as String
var vStringDate as String
var vVisitString as String
var vRecordNumber as String
var vDate as String
var vDateString as String
var vSelectedDate as Date
//vPhysicalData = @GlobalValue ("CurrentRecList")
//vRecordNumber = @AccessStringArray(vPhysicalData, 1)
vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart) // Since Physical also have Chart element and Chart# never changes
if(vRSHandle > -1)
{
vTotalRecords = @XResultSetTotal(vRSHandle)
for vLoop = 1 to vTotalRecords
XResultSetCurrentPosition(vRSHandle, vLoop)
vVisitDate = @XResultSetValue(vRSHandle, "Date1")
If vVisitString = "" then
{
vVisitString = vVisitDate
}
Else
{
vVisitString = vVisitString + ";" + vVisitDate
}
next
vVisitString = @SortStringArray (VVisitString, 0)
vVisitString = @ReverseStringArray (vVisitString)
XResultSetClose(vRSHandle)
}
For vLoop = 1 to @CountStringArray(vVisitString)
vDate = FormatDate (@AccessStringArray (vVisitString, vLoop))
If vDateString = "" then
{
vDateString = vDate
}
Else
{
vDateString = vDateString + ";" + vDate
}
next
//Writeln (vDateString)
PopupSelectPosition(4, @Xpos(ThisElement), @Ypos(ThisElement))
vSelectedDate = @PopupChoiceList(vDateString, "Select DATE")
If vSelectedDate <> "" Then
{
vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart="+ Chart, "!Date1="+ vSelectedDate) //Since the chart# does not change, it is preferable to RecNumber that could change
if(vRSHandle > -1)
{
WarningLevel(0)
XResultSetOpenForm(vRSHandle, "Physical")
WarningLevel(1)
XResultSetClose(vRSHandle)
}
}