Normal Topic Initial Values (Read 696 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Initial Values
Dec 29th, 2005 at 8:35pm
Print Post Print Post  
Ray (et. al.) -

As you suggested, I am trying to "clean up" my databases with regard to initial values so that I will not be creating "blank" forms.

Each time I create a new form for addition to my database, I want it assigned a consexutive unique number that satisfies two conditions.

1)  I only need the ID number if data is entered in one or more Layout Elements on the form.

2)  In some cases, I need to see the ID number before I exit the form.

Rarely, if ever, will I enter or click on the ID LE.  

One exception is that, in rare cases, I will manually input a number in the ID LE to enter a "skipped" form number. In these cases, the ID Number would generally be the first entry I make to the form.

Presently I have the following code in my ID field for the Event On Form Entry

Code
Select All
if @isnew and ID = "" then id = @number 


If I move the same code to the event On Form Change, will that accomplish what I want?

Also, is there a better way to approach this?

Finally (for now), there are two other points I am confused about.

(1)  If I search for and receive a "set" of six forms, and then advance to a "blank" form and, without having entered any data, then press F9, what will happen to the "blank" form (1) if it does have an initial value in one of the layout elements and (2) if it does NOT have an initial value in one of the LE's?

(2) Assuming that if I press F10 and then, before entering data, press F9, and I have used an initial value in one of the fields, the form will be "saved." If so, is there ever a time when I can use an initial value and not have the form saved under any circumstance, when that is the only field containing a value?

Thanks!

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
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: Initial Values
Reply #1 - Dec 29th, 2005 at 8:55pm
Print Post Print Post  
Hello Spencer,

Try something like
Code
Select All
If @IsNew And @IsBlank(ID) And @IsBlank(First Name) = 0 Then id = @number 



in perhaps the On Form Change event.

-Ray
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Initial Values
Reply #2 - Dec 29th, 2005 at 9:09pm
Print Post Print Post  
Ray -

In that case, and if I understand the code correctly, a number won't be assigned even if every LE has an entry EXCEPT for the first name field.

I am assuming that "On Form Change" would require me to make an entry into one (or more) of the LE's.  If all I do is "enter" an "exit" a blank form will "on form change" programming come into play even in that instance?

Can you point out what would be wrong with the change I proposed?

Also I am not clear as to why would I need the @isblank(First Name) = 0 ... when I don't need the = 0 for @isblank(ID).

There were several other points, in my original message, that I would appreciate having addressed.

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Initial Values
Reply #3 - Dec 29th, 2005 at 10:04pm
Print Post Print Post  
Quote:
I am assuming that "On Form Change" would require me to make an entry into one (or more) of the LE's.  If all I do is "enter" an "exit" a blank form will "on form change" programming come into play even in that instance?


Use the On Element Change event of the Form itself. This will run when you change any value without having to put the code in more than one place. The code will not occur simply because you arrive at and leave a Form unless you have On Form Entry or On Form Exit code that changes a value.

Quote:
Can you point out what would be wrong with the change I proposed?


The main thing is that you are checking for ID = "" instead of using @IsBlank, which is type safe.

Quote:
Also I am not clear as to why would I need the @isblank(First Name) = 0 ... when I don't need the = 0 for @isblank(ID).


Because it is the opposite condition. One checks for blank, the other checks for not blank.
These two lines do the same thing:
If @IsBlank(ID)
If @IsBlank(ID) = 1

And these two lines do the same thing:
If Not @IsBlank(ID)
If @IsBlank(ID) = 0


Quote:
There were several other points, in my original message, that I would appreciate having addressed.


OK.

Quote:
(1)  If I search for and receive a "set" of six forms, and then advance to a "blank" form and, without having entered any data, then press F9, what will happen to the "blank" form (1) if it does have an initial value in one of the layout elements and (2) if it does NOT have an initial value in one of the LE's?


To answer your question, we need to distinguish between an Initial Value and a value set in programming On Form Entry.

If you F9 from a new record that has Initial Values, but no value has been changed, the blank will be discarded as it is considered to be unchanged. If you F9 from a new record that has values set On Form Entry, the record will be saved, because this counts as a changed (no longer blank and unmodified) record.

Quote:
(2) Assuming that if I press F10 and then, before entering data, press F9, and I have used an initial value in one of the fields, the form will be "saved." If so, is there ever a time when I can use an initial value and not have the form saved under any circumstance, when that is the only field containing a value?


Again, initial values and values set On Form Entry are not the same thing. If you use Initial Values and they are not changed, the form will not be saved.
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Initial Values
Reply #4 - Dec 29th, 2005 at 10:20pm
Print Post Print Post  
By George, I think I've got it.

The = "" was just old programming before you told me for the 1st, 2nd, 3rd, 4th etc. time NOT to use it.  lol

I've only used if not @isblank so the = 0 threw me.  I should have figured it out because I know we were looking to see whether the First Name LE contained data.

So, now I can just concern myself with on form entry progamming and don't have to worry about initial values (for my present need).

Thank you.

27 MORE DAYS!!!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Initial Values
Reply #5 - Dec 29th, 2005 at 10:45pm
Print Post Print Post  
Hooray -

Another irritant - the problem of "blank" records - since "Day One" (for me) has now been resolved. 

I now have my initial values - and form programming (done correctly) so that I don't wind up with blank records.  It's like "having my cake, and eating, it too" and that's the way it should always be.  lol

Thanks again!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged