Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) I copied this directly from the Guide so... (Read 2501 times)
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
I copied this directly from the Guide so...
Dec 17th, 2005 at 12:59am
Print Post Print Post  
where is the error???  Ok, I give up. I fully expect to feel like a fool once this is answered but at least my button will work:-[

Le44 is the field that needs to  not* be blank before adding the record. The book had Add1 which I "assumed" was a generic field name so I changed it to mine. The button's name is Ticket.
************************************

If(Le44 <> "")


{

          CreateNewRecord()

}


____________________________________
Error String
Error while parsing module "Ticket(0)":
Symbol expected [}], symbol found [Identifier].
Line 11, position 9: [Identifier: CreateNewRecord]
CreateNewRecord()
             ^

**********************

I spent most of the day on this one thing & have gotten nowhere.  Please put me out of my misery. (Unfortunately I am leaving so will not find out till Sunday at the earliest)

~Natalie Tongue

*Added the "not" to clarify for anyone else who came along. I forgot it first time, much to my embaressment
Undecided
« Last Edit: Jan 20th, 2006 at 6:01pm by digimom1962 »  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: I copied this directly from the Guide so...
Reply #1 - Dec 17th, 2005 at 1:18am
Print Post Print Post  
Try @CreateNewRecord. It believe that it became a function with a returned value after the manual was printed.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: I copied this directly from the Guide so...
Reply #2 - Dec 17th, 2005 at 4:00am
Print Post Print Post  
Quote:
Le44 is the field that needs to be blank


Try this:
========================
var vOK as Int

If @IsBlank(Le44)  Then {
          vOK = @CreateNewRecord()
          }

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



  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #3 - Dec 17th, 2005 at 2:56pm
Print Post Print Post  
FYI, from the programming guide (page 36):
CreateNewRecord() Saves current record, creates new record, and goes to it. Any code that follows is run on the new record.
@CreateNewRecord() Same as CreateNewRecord() except returns a number indicating the result set position of the new record

Bob,
You missed one detail. She wants to execute the code if LE44<>"".

Natalie,
Change the @IsBlank(Le44) part to this:
Not @IsBlank(Le44)

EDIT: Natalie, you can ignore this post. Bob pointed out to me that you meant to have the code execute only if Le44 was empty. I was looking at your code, which indicated that you wanted to execute only if it was NOT empty. His 1st response here is the one you should use.
« Last Edit: Dec 17th, 2005 at 7:30pm by Carl Underwood »  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #4 - Dec 17th, 2005 at 3:08pm
Print Post Print Post  
I see what Mark meant, now.

I just did some testing, and CreateNewRecord() (the one without the "@" symbol) does not seem to be a valid command or function in the latest release.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: I copied this directly from the Guide so...
Reply #5 - Dec 17th, 2005 at 5:50pm
Print Post Print Post  
Carl, note that she said Le44 MUST BE BLANK.

That has been the major problem, besides the CreatreNewRecord issue.  If you use <>"" then you will only create a new record if something is in Le44.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #6 - Dec 17th, 2005 at 7:22pm
Print Post Print Post  
Quote:
Carl, note that she said Le44 MUST BE BLANK.

Hmmm. Well, I guess you understood her intentions, while I was strictly looking at the code. ???

Quote:
That has been the major problem, besides the CreatreNewRecord issue.  If you use <>"" then you will only create a new record if something is in Le44.

I agreed with you, that she should use @IsBlank instead of <>"", I was just pointing out that (I thought) she needed to include "Not" before it.



  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: I copied this directly from the Guide so...
Reply #7 - Dec 17th, 2005 at 7:53pm
Print Post Print Post  
Quote:
I see what Mark meant, now.

I just did some testing, and CreateNewRecord() (the one without the "@" symbol) does not seem to be a valid command or function in the latest release.


From the change log (I don't the historic source code here at home, just the current version), it appears that the name was changed with 1.0.2, which would be quite a while ago. I can't be sure that there were not two versions for some time, one with the "@" and one without. But it seems more likely to me that the documentation is in error. I suspect that when the command was renamed, the documenters took it as a new command and added it to the documentation, rather than having it replace the older command.

I may be wrong about what exactly happened. I do remember that this command was originally named just "New", and then got renamed "NewRecord", then got renamed "CreateNewRecord", then got renamed "@CreateNewRecord" Most of this happened before Sesame 1.0 was released. But this does make this command, the "Prince" of commands.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: I copied this directly from the Guide so...
Reply #8 - Dec 17th, 2005 at 9:26pm
Print Post Print Post  
Carl, you may be right, but I read the intention vs. the code. I did the same as you the first time I looked at this, then did a reread, and thought the code was wrong from the beginning.

The intent is usually more correct than the code, right?  That is why we usually end up debugging the code.

On Monday, natalie will clarify this for us.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #9 - Dec 17th, 2005 at 10:35pm
Print Post Print Post  
Quote:
The intent is usually more correct than the code, right?

Yes, absolutely!
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
Re: I copied this directly from the Guide so...
Reply #10 - Dec 19th, 2005 at 1:07am
Print Post Print Post  
I intend to pay more attention. Scouts honor!

I actually DID want le44 to not be blank.  Embarrassed (That was apparently the only thing I got right)

I will not be back on till Friday. I will closely examine the situation and ask a coherent question then.

Briefly, what I am trying to ad is a subform and the field that needs to be not blank is on the subform. To really make it a mare's nest, I had somehow gotten the subform and the field I need to not be blank to have the same name. (My 8th grade english teacher is spinning in her grave after THAT sentence structure)

I did get it to ad a form thank you very much. It added the parent form of course. I saw a few other comands specific to subforms and I will investigate them Friday.

Thanx again
~Natalie
(sleep deprived again and it shows Tongue)
  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: I copied this directly from the Guide so...
Reply #11 - Dec 19th, 2005 at 1:41am
Print Post Print Post  
So, as you now change the spec, Le44 should NOT be blank.  Then as Carl noted, modify the earlier code to this:

======================== 
var vOK as Int

If NOT @IsBlank(Le44)  Then {
     vOK = @CreateNewRecord()
     }

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

But it also sounds like we are working at the wrong level of forms?  Waiting to see how you want it the next time. 

Take a break, it does wonders. Grin
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #12 - Dec 19th, 2005 at 5:25am
Print Post Print Post  
Natalie,

Bob is correct, "we are working at the wrong level of forms".

To add a new record to a subform, you need to use @FormNewRecord("MySubform") rather than @CreateNewRecord().

To check the content of a LE in a subform, you need to use @FormFieldValue("MySubform", "MySubformLE", SubformInstance).

Based on what I believe you are asking, this is the general structure you probably need to use:
Code
Select All
var nn as int

if @FormFieldValue("MySubform", "MySubformLE", SubformInstance) <> ""		//Check if subform LE is not blank
	{
	nn = @FormNewRecord("MySubform")
	FormFieldValue("MySubform", "MySubformLE", nn, MyValue)		//Post to new subform record. nn is the subform instance created above.
	}
 


The last line demonstrates how you would post data to the subform record. It will post a value to the newly created record.

You also need to figure out which instance of subform to check, for the blank LE. If you simply need to check the last one, you can use @FormResultSetTotal("MySubform") to find it.

------------------------------------------------------------------------

The previous info is based on what I first thought you asked for. But, it also sounds like you may want to use the following code instead. It will add a new subform record every time you click on the Ticket button, except when you don't have any subform data yet (like when the parent is new). It will check the first subform instance to see if it is blank. If it is blank, it will add the data to that first subform record. Otherwise, it will add a new subform record, and post the data to the new one.
Code
Select All
var nn as int

if @FormFieldValue("MySubform", "MySubformLE", 1) <> ""
	nn = @FormNewRecord("MySubform")
else
	nn = 1

FormFieldValue("MySubform", "MySubformLE", nn, MyValue)
 


This is actual code that I am using in one of my apps.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: I copied this directly from the Guide so...
Reply #13 - Dec 19th, 2005 at 6:08am
Print Post Print Post  
Good work Carl, well explained....but curious ???

It looks like you also fell back into the Q&A <>"" vs, NOT @IsBlank

Old habits are hard to break Roll Eyes
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: I copied this directly from the Guide so...
Reply #14 - Dec 19th, 2005 at 6:10am
Print Post Print Post  
@IsBlank does not work for subforms when the code that is running is in the parent form. (Or at least that seems to be what I remember finding out.)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print