Normal Topic click FormA field to open FormB specific record (Read 956 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
click FormA field to open FormB specific record
Mar 25th, 2013 at 10:16pm
Print Post Print Post  
My Client form contains a field LastSONum that contains the last sales order number from this client's last sales order in my Orders database.  What I want to do is be able to just click the cursor into this Client!LastSONum field, and have Sesame open the Orders form and retrieve this LastSONum sales order number.  I'm stumped at how to progress past the opening of the Orders Form.  Here's where I'm at ...

If @Mode() = 1
   {//2a
     vLastSONum = ""
     vLastSONum = LastSONum
     If vLastSONum <> ""
       {

           n = @SelectTreeItem("WordCom-BBC!Forms!Search/Update!Orders!Orders")
       }

     
   }
  

Larry
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: click FormA field to open FormB specific record
Reply #1 - Mar 26th, 2013 at 1:32am
Print Post Print Post  
You will have to use @ClientLocalValue () command and also RetrieveSpecOpen Event code if you want to use @SelectTreeItem ( )

You can also use @XResultSetOpenForm ( ) command and achieve the same thing.

I will give examples of both from my codes so name of the form and Element names will be different but you will get the idea:

IndexView is a commandButton

IndexView: On ElementEntry Event

var vTmp as Int


ClientLocalValue("CurrentRecord", RecNumber)


     WarningLevel(0)
     vTmp = @SelectTreeItem(@Application + "!Forms!Search/Update!Index!Index")
     WarningLevel(1)



On Retrieve Spec Open Event
RecNumber:

var vStr as String

IF @ClientLocalValue ("CurrentRecord") <> "" then
     {
           RecNumber = @ClientLocalValue ("CurrentRecord")
                //Reset ClientLocalValue
                @ClientLocalValue ("CurrentRecord", "" )
           vStr = @SpecCommand (2, 1, "")
     }


================================

Same thing can be achieved a lot easier way using just following:

var vRSHandle as Int

vRSHandle = @XResultSetSearch(@FN, "Index", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber)
     if(vRSHandle > -1)
           {
                 WarningLevel(0)
                 XResultSetOpenForm(vRSHandle, "Established")
                 WarningLevel(1)

                 XResultSetClose(vRSHandle)
           }




« Last Edit: Mar 26th, 2013 at 4:26am by Bharat_Naik »  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: click FormA field to open FormB specific record
Reply #2 - Mar 26th, 2013 at 2:45am
Print Post Print Post  
Bharat,

I will try the XResultSetOpenForm method first. 

In the 4 years I've been programming in Sesame, I have never delved into ClientLocalValue.  But I will study your code above, and shamelessly use it as my guide. 

This will open up a whole new level of convenience in many areas of my application suite.  Thank you!


Larry
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: click FormA field to open FormB specific record
Reply #3 - Mar 26th, 2013 at 4:56am
Print Post Print Post  
Bharat,

XResultSetOpenForm  worked great!  What a nifty tool.  Thank you so much.

Larry
  

Larry
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: click FormA field to open FormB specific record
Reply #4 - Mar 26th, 2013 at 6:22am
Print Post Print Post  
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: 

Code
Select All
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)
				}
	}
 

  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: click FormA field to open FormB specific record
Reply #5 - Mar 26th, 2013 at 1:05pm
Print Post Print Post  
Yes!  Great idea!  I use similar technique during Sales Order creation to pull up a pop up list of inventory items that the involved client uses, and choosing an item in the pop up window loads the ItemNum field with the chosen ItemNum.  But I never thought to extend that functionality to jumping to other specific forms/databases.   

Again, thanks so much.  I'll be incorporating this additional twist before the day is over.
  

Larry
Back to top
IP Logged