To Clarify a little further, I have following code which is activated by command button.
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
vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber=" + RecNumber)
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, "!RecNumber="+ RecNumber, "!Date1="+ vSelectedDate)
if(vRSHandle > -1)
{
WarningLevel(0)
XResultSetOpenForm(vRSHandle, "Physical")
WarningLevel(1)
XResultSetClose(vRSHandle)
}
}
This is will display Popup with Dates patient was seen and selecting the date will display the physical exam form for the date. If you select one date, the first time the record with two subforms with medications display fine. But if you choose the different date (with the physical form with earlier record displayed, the main form data will change appropriately but the subform data remained unchanged that belonged to the earlier record. I hope this will make it a little clearer. Thanks.