Normal Topic FormCommit or selecttreeitem (Read 1977 times)
Wilder
Member
*
Offline



Posts: 25
Joined: Jun 11th, 2015
FormCommit or selecttreeitem
Jun 14th, 2015 at 11:02pm
Print Post Print Post  
Hello
I am new to Sesame but have been programming in various languages since the early 70.

I am working on a project that involves importing data that would normally be typed in.  I am reading a CSV file that was downloaded from the vendor with the items that they are paying for.
I set up one form for the manual entry of data when no CSV is available.

I have a second form that is called as a dialog to enter the information about the CSV file.   ie which column the required data is in and the file location.
The file is read and posted into the manual entry form.

The problem I am having is that "FormCommit(Manual entry form) fails to save the records on the manual entry form.  I also have tried to use the selecttreeitem, but it also fails.   

The last record in the CSV file is the only one that gets saved.

Using the Form as dialog I can see the CSV records as they are placed in the manual entry form.

Two forms involved one working on the other but the save records is not working correctly.

Any help would be greatly appreciated.

Attached is the code for the form that is doing the work.
  

Import_Comm.txt ( 8 KB | 30 Downloads )
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: FormCommit or selecttreeitem
Reply #1 - Jun 15th, 2015 at 4:19pm
Print Post Print Post  
You never advance to a new record position, so you are simply overwriting the same record with new data until it reaches the final line in the csv file. Thus, you end up with one record, showing the info from the last line of the file.
  


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: FormCommit or selecttreeitem
Reply #2 - Jun 15th, 2015 at 4:23pm
Print Post Print Post  
BTW, "Goto" has been deprecated. Plus, I've never seen it used with labels before (e.g. "Jump_Error:"). I wasn't even aware (or had forgotten if I once did know) that you can use Goto with labels. It's normally used to send focus to another layout element.
  


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



Posts: 25
Joined: Jun 11th, 2015
Re: FormCommit or selecttreeitem
Reply #3 - Jun 16th, 2015 at 12:36pm
Print Post Print Post  
I'm old School, always used goto to jump around in a program.   Don't need to go to another element.

Started out programming in Fortran, then RPG, RPG II, RPG III, Cobol,  Basic, C++.  GOTO with Label has always been my JUMP tool.

Also I have fix My problem with the record overlay.

Thanks for the info.
  
Back to top
 
IP Logged
 
Wilder
Member
*
Offline



Posts: 25
Joined: Jun 11th, 2015
Re: FormCommit or selecttreeitem
Reply #4 - Jun 16th, 2015 at 7:43pm
Print Post Print Post  
Thought I had my problem fixed but not all of my fields are posting with the xresultsetvalue command.  some of them post but some dont.

all fields will post with formFieldValue  but It does not move to a new record with FormFieldvalue.
What command will cause it to move to the next available record?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: FormCommit or selecttreeitem
Reply #5 - Jun 16th, 2015 at 8:38pm
Print Post Print Post  
Have a look at @CreateNewRecord().
  


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



Posts: 25
Joined: Jun 11th, 2015
Re: FormCommit or selecttreeitem
Reply #6 - Jun 17th, 2015 at 1:09pm
Print Post Print Post  
Thanks for the Information.

Had to use @formnewrecord because I have 7 files in this database.
and @formCommit() to set the record.

Also I don't know if this is a problem or not, but I tried to do the same thing with Xresultsetvalue and had problems with not all of the fields posting.  Using FormFieldValue all of the fields posted.

Below is a copy of the lines used for both.   I can not find a reason why some fields would post and other would not.   I have marked the lines that failed to post.


Pointer = @FormNewRecord("Commission_Entry")      
           
     if(pointer > -1)
     {

//      FormFieldValue(formName, name, instance,newval)
     formfieldvalue("Commission_Entry", "Statement_Date", Pointer, Statement_Date)
     formfieldvalue("Commission_Entry", "Date_Paid", Pointer, Date_Paid)
     formfieldvalue("Commission_Entry", "PolicyNum", Pointer, Policy_no)
     formfieldvalue("Commission_Entry", "Holder_Last_Name", Pointer, PHLName)
     formfieldvalue("Commission_Entry", "First_Name", Pointer, PHFName)
     formfieldvalue("Commission_Entry", "Agent_No", Pointer, Agent_No)
     formfieldvalue("Commission_Entry", "Agent_Name", Pointer, Agent_name)
     formfieldvalue("Commission_Entry", "Company0", Pointer, Company)
     formfieldvalue("Commission_Entry", "Due_Date", Pointer, Due_Date)
     formfieldvalue("Commission_Entry", "Entry_Code", Pointer, "1")
     formfieldvalue("Commission_Entry", "Commission_Amt", Pointer, Commission_Amt)
     formfieldvalue("Commission_Entry", "Commission_Note", Pointer, Note)
     formfieldvalue("Commission_Entry", "Issue_Date", Pointer, Issue_Date)
     formfieldvalue("Commission_Entry", "Type0", Pointer, Type0)
     formfieldvalue("Commission_Entry", "Annual_Premium", Pointer, Annual_Premium)
     formfieldvalue("Commission_Entry", "Mode", Pointer, Mode)
     formfieldvalue("Commission_Entry", "Commission_Base", Pointer, Commission_Base)
     formfieldvalue("Commission_Entry", "Commission_Pct", Pointer, Commission_Pct)
     formfieldvalue("Commission_Entry", "Mode_Percent", Pointer, Mode_Percent)
     formfieldvalue("Commission_Entry", "New_Due_Date", Pointer, New_Due_Date)      
     formfieldvalue("Commission_Entry", "Plan", Pointer, Plan)      
     
     FormCommit("Commission_Entry")
=================================================================

did not include the "Create result set "

     XResultSetCreateNewRecord(pointer)
     xresultsetvalue(Pointer, "Statement_Date", Statement_Date)
     xresultsetvalue(Pointer, "Date_Paid", Date_Paid)
     xresultsetvalue(Pointer, "PolicyNum", Policy_No)                       <<<<<<<<<<<<<<
     xresultsetvalue(Pointer, "Holder_Last_Name", PHLName)           <<<<<<<<<<<<<<
     xresultsetvalue(Pointer, "First_Name", PHFName)
     xresultsetvalue(Pointer, "Agent_No", Agent_No)
     xresultsetvalue(Pointer, "Agent_Name", Agent_Name)
     xresultsetvalue(Pointer, "Company0", Company)                         <<<<<<<<<<<<<
     xresultsetvalue(Pointer, "Due_Date", Due_Date)
     xresultsetvalue(Pointer, "Entry_Code", "1")
     xresultsetvalue(Pointer, "Commission_Amt", Commission_Amt)    <<<<<<<<<<<<<
     xresultsetvalue(Pointer, "Commission_Note", Note)
     xresultsetvalue(Pointer, "Issue_Date", Issue_Date)
     xresultsetvalue(Pointer, "Type0", Type0)
     xresultsetvalue(Pointer, "Annual_Premium", Annual_Premium)
     xresultsetvalue(Pointer, "Mode", Mode)
     xresultsetvalue(Pointer, "Commission_Base", Commission_Base)
     xresultsetvalue(Pointer, "Commission_Pct", Commission_Pct)         <<<<<<<<<<<<<
     xresultsetvalue(Pointer, "Mode_Percent", Mode_Percent)
     xresultsetvalue(Pointer, "New_Due_Date", New_Due_Date)
     xresultsetvalue(Pointer, "Plan", Plan)

If anyone can see why they failed to post,  please let me know.

Thanks 
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: FormCommit or selecttreeitem
Reply #7 - Jun 17th, 2015 at 7:00pm
Print Post Print Post  
I have found in the past that I need to have XResultSetCurrentPosition() before every XResultSetValue().

For example:
XResultSetCurrentPosition(vRS, i)
XResultSetValue(vRS, "TDate", InvDate)
XResultSetCurrentPosition(vRS, i)
XResultSetValue(vRS, "Name", Name)
XResultSetCurrentPosition(vRS, i)
XResultSetValue(vRS, "Amount", Invoice Amt)
XResultSetCurrentPosition(vRS, i)
XResultSetValue(vRS, "PmtType", "")


Not sure if this is still the case. I haven't tested it lately.
  


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: FormCommit or selecttreeitem
Reply #8 - Jun 17th, 2015 at 7:04pm
Print Post Print Post  
BTW, you may also experience some issues if the form is open AND you are modifying it with XResultSetValue() at the same time. I've successfully done this before, but it required that I have focus on the last record in the result set. This particular case involved a subform.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: FormCommit or selecttreeitem
Reply #9 - Jun 17th, 2015 at 7:12pm
Print Post Print Post  
Wilder wrote on Jun 17th, 2015 at 1:09pm:
Thanks for the Information.

Had to use @formnewrecord because I have 7 files in this database.
and @formCommit() to set the record.

Also I don't know if this is a problem or not, but I tried to do the same thing with Xresultsetvalue and had problems with not all of the fields posting.  Using FormFieldValue all of the fields posted.

Below is a copy of the lines used for both.   I can not find a reason why some fields would post and other would not.   I have marked the lines that failed to post.



If your code is setting some fields but not others double check that you have the names correct. FormFieldValue() uses Element names but the XResult commands use the underlying field names which may be different than the element names. Field names are the "Bound To:" property in the Property Viewer.

Carl Underwood wrote on Jun 17th, 2015 at 7:00pm:
I have found in the past that I need to have XResultSetCurrentPosition() before every XResultSetValue().



There is no need that I know of in 2.6 to use XResultSetCurrentPosition() before each XResultSetValue() call.

Carl Underwood wrote on Jun 17th, 2015 at 7:04pm:
BTW, you may also experience some issues if the form is open AND you are modifying it with XResultSetValue() at the same time. I've successfully done this before, but it required that I have focus on the last record in the result set. This particular case involved a subform.


I highly recommend that you never use XResultSetValue() to change the values on records that the current client has open, especially if it is the current record open in the form as when the form saves it will save the record over the one modified by XResultSetValue().

-Ray
  

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