Normal Topic Blank Subrecords Being Saved (Read 578 times)
Acebanner
Full Member
***
Offline



Posts: 123
Location: New York City
Joined: Jan 23rd, 2008
Blank Subrecords Being Saved
Jul 1st, 2008 at 1:19pm
Print Post Print Post  
I'm having a strange problem with subrecords.

I've created a CLIENTS database with a subform that I intend to use to list related records in a second database called JOBS.
I am linking the records relationally, using a keyfield named 'clientnumber'.
I don't want the user to be able to add JOB records using the CLIENTS form, it's just to see the information. The problem I'm having is that when I Search/Update the CLIENTS form, blank records are being shown (for clients who do not yet have any related job record), and as I F10 through the records, Sesame is actually saving those blank records to the JOBS database.

I've made the subform Read-Only -- didn't work.
I've tried adding @StandAlone = 0 and NotifyForm(1) on both Form Entry and Form Exit events (alone and in tandem) for the JOBS form, but that doesn't prevent the blank records from being saved.

I'm sure there has to be something simple that I'm missing.

The subrecords are not using natural links because I would prefer that JOB records remain as orphans, in the event of the parent record (in CLIENTS) being deleted.

Any help would be appreciated.  Undecided
  
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: Blank Subrecords Being Saved
Reply #1 - Jul 1st, 2008 at 1:36pm
Print Post Print Post  
In what event are you filling in the clientnumber field on the Jobs subform records?
What does that code look like?

-Ray
  

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



Posts: 123
Location: New York City
Joined: Jan 23rd, 2008
Re: Blank Subrecords Being Saved
Reply #2 - Jul 2nd, 2008 at 3:53pm
Print Post Print Post  
Ok, I think I solved this one.

My code for filling in the 'EstimateNumber' field fires on Form Exit. Here it is:

Code
Select All
// Only assign the number if this is a new record which has been changed.

var vNextNum as Int

If @Mode() = 0 // We are in Add Mode.
{
	    If (@Modified) // The record has been modified.
	    {
		  If (@IsBlank(COMPANYNAME) <> 1) AND (@IsBlank(DESCRIPTION) <> 1) AND (@IsBlank(ESTIMATENUMBER) = 1)// neither COMPANYNAME nor DESCRIPTION ARE BLANK, and ESTIMATENUMBER is blank
		{
			vNextNum = @ToNumber(@GlobalValue("gvEstimateNumber")) + 1
			  EstimateNumber = vNextNum
			  GlobalValue("gvEstimateNumber", @Str(vNextNum))
			//Write("Form Exited -- in Add Mode, record changed, met restrictions. EstimateNumber updated." + @NEWLINE())
		}
		Else // Restrictions not met!
		{
			If (@IsBlank(COMPANYNAME) <> 1) AND (@IsBlank(DESCRIPTION) <> 1) AND (@IsBlank(ESTIMATENUMBER) <> 1)
			{
				//@MsgBox("Add Mode, Modified,","Restrictions Met","ESTIMATENUMBER pre-existing - SAVED")
			}
			Else
			{
				NotifyForm(1) // prevent saving.
				//@MsgBox("This job was not issued a job number and saved because:","either COMPANYNAME or DESCRIPTION field were blank","or this job had already been given a job number.")
			}
		}
	}
	Else
	{
		//Write("Form Exited -- in Add Mode, record NOT changed. ESTIMATENUMBER NOT updated." + @NEWLINE())
	}
}
Else
{
	//Write("Form Exited -- not in Add Mode, ESTIMATENUMBER NOT updated." + @NEWLINE())
} 



That programming appears on the ESTIMATES form.
The CLIENTS form (which has "ESTIMATES" as a relationally linked subform) stopped saving blank estimate records once I added the following programming statements to CLIENTS:Shockedn Form Entry

Code
Select All
FormNotifyForm("ESTIMATESabbrev", 1)	//Do not allow saving of subrecords. 



'ESTIMATESabbrev' is a copy of the original layout, with extra LE's removed.

So I think I figured out what to do, but I have a new problem now.
I updated my "sbasic_include.sbas" file (it's in the directory C:/Sesame2, like the old file) and now suddenly none of my XResultSet commands seem to be working. Even when I go back to an earlier copy of the application I'm developing, the programming no longer works. Is that likely to be the result of a 'bad' include file?
  
Back to top
IP Logged