Hello,
I've worked with Nav 5.1 on SQL for a few years but now I'm trying to learn some simple programming. I've searched the forum on this topic but I can't find a detailed enough example that I can get to work. This is just for me to learn, it has no valid application at this point.
I have two tables and a form. I use the form to add records to the StudentApplicant table. If the student gets accepted I want to move the record out of the StudentApplicant table an into the EnrolledStudent table. The tables are layed out identically with a No., Name, and Age field. I have a command button on the StudentApplicant form.
My variables are
EnrolledStudent as type Record and sub type EnrolledStudent table
StudentApplicant as type Record and sub type StudentApplicant
My code i've tried and is pieced together from this forum is
EnrolledStudent.SETRANGE("No.", StudentApplicant."No.");
IF EnrolledStudent.FIND('-') THEN BEGIN
EnrolledStudent.Name := StudentApplicant.Name;
EnrolledStudent.Age := StudentApplicant.Age;
EnrolledStudent.MODIFY;
END ELSE BEGIN
Clear(EnrolledStudent);
EnrolledStudent."No." := StudentApplicant."No.";
EnrolledStudent.Name := StudentApplicant.Name;
EnrolledStudent.Age := StudentApplicant.Age;
EnrolledStudent.INSERT(TRUE);
END;
I created a processing only report and put this code in the OnPreDataItem section and run it from the command button but all that happens is a blank row is created in the EnrolledStudent table.
Can anyone point out what I'm doing wrong? It seems easy enough but I'm getting really frustrated.
Eventually, I'd like to try this on a table that uses number series but this is just using the No. as type code. I also don't think using the TRANSFERFIELDS function is a good idea because the two tables may not be identical in the near future.
0
Comments
You'll need code like
You can liken a dataitem in a report with the following structure of code:
For an application like this, you should design the two tables with matching field numbers for matching fields. Then you can use the TRANSFERFIELDS function instead of a long row of field assignments.