Normal Topic FormExit help (Read 738 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
FormExit help
Mar 22nd, 2012 at 8:26pm
Print Post Print Post  
The code below works great to create a new record in the Client database from the Dead database, open the Client database to the newly made record, delete the record in the Dead database if wanted, then close the Dead database.

Code
Select All
var vRS as Int
var vRS2 as Int

	//Get blank XResultset for Client database
	vRS = @XResultSetSearch(@FN,"Client", 0, 2, "")   
	If vRS > -1
	{
		//Create new Record in Clients database
		XResultsetCreatenewRecord(vRS)

		//Set the field values- CLIENT .DB   DEAD .DB
		XResultSetValue(vRS, "Last Name", Last Name)

		XResultSetClose(vRS)
	}

	//Search for newly made client record based on DEAD record Last Name and Address
	vRS2 = @XResultSetSearch(@FN,"Client", 0, 2, "!Last Name=" + Last Name, "!Address=" + Address)   
	If vRS2 > -1
	{
		XResultSetOpenForm(vRS2, "Client") //Open new Client record
		XResultSetClose(vRS2)
	}

	//Ask if "copied" DEAD record should be deleted
	If @Askuser("Do you want to permanently","delete this Dead database record","before proceeding?") Then
		{
			WarningLevel(0) //Do not prompt about removing record
			DeleteRecord()
			WarningLevel(1)
		}

@Exit
 


If the Client database is open in search mode, no problem. If Client is open in update, the new record does not get made. So, I thought that I would first close the Client database using FormExit like shown below, but the FormExit code does not trigger. If I run just the four lines of the FormExit code and nothing else, it closes Client without issue. FYI - I realize that I probably don't need vRS and vRS2, but was using it in testing.
Code
Select All
var vRS as Int
var vRS2 as Int

vCloseClient = @XResultSetForm("Client")

	If vCloseClient >=0 then
	{
		FormExit("Client")
		XResultSetClose(vCloseClient)
	}

	//Get blank XResultset for Client database
	vRS = @XResultSetSearch(@FN,"Client", 0, 2, "")   
	If vRS > -1
	{
		//Create new Record in Clients database
		XResultsetCreatenewRecord(vRS)

		//Set the field values- CLIENT .DB   DEAD .DB
		XResultSetValue(vRS, "Last Name", Last Name)

		XResultSetClose(vRS)
	}

	//Search for newly made client record based on DEAD record Last Name and Address
	vRS2 = @XResultSetSearch(@FN,"Client", 0, 2, "!Last Name=" + Last Name, "!Address=" + Address)   
	If vRS2 > -1
	{
		XResultSetOpenForm(vRS2, "Client") //Open new Client record
		XResultSetClose(vRS2)
	}

	//Ask if "copied" DEAD record should be deleted
	If @Askuser("Do you want to permanently","delete this Dead database record","before proceeding?") Then
		{
			WarningLevel(0) //Do not prompt about removing record
			DeleteRecord()
			WarningLevel(1)
		}

@Exit
 


What am I missing?

Thanks

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormExit help
Reply #1 - Mar 23rd, 2012 at 7:36pm
Print Post Print Post  
Hi Brandon,

tcgeo wrote on Mar 22nd, 2012 at 8:26pm:
....If Client is open in update, the new record does not get made....


Are you 100% sure the record is not being created in the clients database?

tcgeo wrote on Mar 22nd, 2012 at 8:26pm:
So, I thought that I would first close the Client database using FormExit like shown below, but the FormExit code does not trigger.


Is it that the FormExit() code is not running or is it possible the Client form can not be closed? Perhaps due to NotifyForm? I would place a debug statement inside that If Statement and see if you are getting in there. The code below it can't have any effect on code that has already run so I'm a bit confused how you are seeing different results.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: FormExit help
Reply #2 - Mar 23rd, 2012 at 10:08pm
Print Post Print Post  
After further review, the new record was being made. The reason I thought that it wasn’t, was that it leaves me looking at a blank Client record in Update mode. When you click “Back to Search Mode” and try to search for the new record it can’t find it. That’s where I was stopping.  I just noticed that when I click “Back to Search Mode” a notification  at the bottom of the screen pops up that says “Setting search mode to match ALL search restrictions”, can’t say that I’ve seen that before, but I can't search for anything then. If you close tab and re-search, it finds the record.

Quote:
Is it that the FormExit() code is not running or is it possible the Client form can not be closed?


I put a writeln in the If statement. The slate does open, but Client did not close. I have the standard “Do Not Enter Extend Mode” code in each database.

Code
Select All
// Do Not Enter Extend Mode
If @Mode() = 1 Then
{
	If @ResultSetCurrentPosition() = @ResultSetTotal() Then
	{	NotifyForm(2)  	}   //allow save, prohibit record advance
	ELSE
	{	NotifyForm(-2)  }   //Don't allow save, Don't prohibit record advance
}
 



I commented it out in the Client database, no change. Also did the same with the Dead database so both are commented out, and this time the Client closed. The record did get made in the Client database but the “open new Client” code does not fire, I get left at the main menu.


I put a writeln(Last Name) in the “open newly made Client” code
Code
Select All
If vRS2 > -1
	{
                Writeln(Last name)      
		XResultSetOpenForm(vRS2, "Client") //Open new Client record
		XResultSetClose(vRS2)
	} 


thinking that maybe the Dead record was closing before @XResultSetSearch had a chance to pick-up the last name, but the slate does open with the last name.

Hope I’m clear enough on this,

Thanks for your help Ray, have a great weekend!

Brandon
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormExit help
Reply #3 - Mar 26th, 2012 at 6:56pm
Print Post Print Post  
tcgeo wrote on Mar 23rd, 2012 at 10:08pm:
After further review, the new record was being made. The reason I thought that it wasn’t, was that it leaves me looking at a blank Client record in Update mode.


One reason I can see for this is if you are running exactly the code you posted, you are filling in only the last name but searching for last name and address. But if what you posted was actually a simplified version of the code, I am not sure why it's not able to find it.

tcgeo wrote on Mar 23rd, 2012 at 10:08pm:
I commented it out in the Client database, no change. Also did the same with the Dead database so both are commented out, and this time the Client closed.


That's not making any sense as 2 doesn't prevent the form from closing. 6 is the only one that I am aware that does.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: FormExit help
Reply #4 - Mar 26th, 2012 at 8:22pm
Print Post Print Post  
Hi Ray,

Yes, a simplified version of the code, I’m filling in 36 fields, total. All the rest is exact.

For the Client form not closing, I’ve told my customer that the client form must be closed before they do the procedure. I also now have a popup asking them to close client, if it’s open, before proceeding. May not be the best solution, but everybody’s happy.

Thanks for looking into this.

Have a great day!

Brandon
  
Back to top
IP Logged