Normal Topic Preventing blank records (Read 681 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Preventing blank records
Mar 9th, 2010 at 6:02pm
Print Post Print Post  
I'm using the following code in all my forms to prevent users from creating blank records by transitioning into Add mode from the last record of Search mode:
Code
Select All
// Prevents entering Extended Mode from Search-Update

IF @Mode() = 1
THEN
	{
	IF @ResultSetCurrentPosition() = @ResultSetTotal()
	THEN
		{
		NotifyForm(NOTIFY_FORM_EXTEND_DISABLED)
		}
	ELSE
		{
		NotifyForm(NOTIFY_FORM_EXTEND_ENABLED)
		}
	} 


However, one user has found a way to create blank records in my Personnel database, and she doesn't know how she's doing it.  Neither do I, but I'm guessing it has to do with using F10 instead of the "Save", "Save-Continue" and "Save-Exit" buttons I've made.

Is there a way to prevent F10 from saving a blank record if, let's say, the field FullName is blank?
  

**
Captain Infinity
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: Preventing blank records
Reply #1 - Mar 9th, 2010 at 6:06pm
Print Post Print Post  
What element/event is the programming that you posted from?
  
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Preventing blank records
Reply #2 - Mar 9th, 2010 at 6:07pm
Print Post Print Post  
Form -> On Form Entry
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Preventing blank records
Reply #3 - Mar 9th, 2010 at 6:11pm
Print Post Print Post  
For starters, you don't have to do the position checking. You can just drop NotifyForm(NOTIFY_FORM_EXTEND_DISABLED) into GLOBAL CODE for the Form and be done with it. Extend Mode does not prevent you from advancing around existing records, only from making new ones.

I'd look at your buttons and see if any of them are setting NotifyForm(NOTIFY_FORM_EXTEND_ENABLED). If they are, take it out.


  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Preventing blank records
Reply #4 - Mar 9th, 2010 at 6:17pm
Print Post Print Post  
Thanks Erica, I will update my code.

On closer examination, I've found that what I thought was a saved blank form is not actually blank.  The value "2,010" exists in the Age field.

This field is calculated on-form-entry by the following code"
Code
Select All
// Calculates the employee's age

IF
(
@MODE( ) = 1
and not
	(
	@IsBlank(Birthdate) and
	Age = (@YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
	or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate))))
	)
)

THEN
	Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
	or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate))) 



This is firing off in Search mode even when Birthdate is blank, so I've written in a bug there somewhere.  Not sure if it's my Mode checking, or the nested "and not", or something else.  Help spotting it would be appreciated.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Preventing blank records
Reply #5 - Mar 9th, 2010 at 6:39pm
Print Post Print Post  
I'm all set, I found a way to stomp it.  Thanks!
  

**
Captain Infinity
Back to top
IP Logged