Hi all, Can anybody throw some light to my problem.I have to get values from another table on the form which contain fields say for eg:fromdt(leave taken from),todt(leave taken upto),employee id to calculate “Leave approved” for an employee.I tried but i didn’t work out. Best regards, Hari.
Declare a global variable as record for your table and add some text fields on the form with source expresion linked to your fields to display.
Hi Marcel, I did that but still no result and here comes the coding, employeeabsence.INIT; IF employeeabsence.FIND('-') THEN BEGIN REPEAT IF (fromdt>=employeeabsence."From Date") AND (todt<=employeeabsence."To Date") AND (Empno=employeeabsence."Employee No.")THEN BEGIN "Leave approved":="Leave approved"+1; END; UNTIL employeeabsence.NEXT=0; END;
Best regards, Hari. -Hari- please use the code start and end tags to make the code more readable.
I’m not sure what you would but : Add a textbox with sourceexpression=“leave approved” on your form Depend what you do, but after you calcute, CurrForm.Update is perhaps needed But another question, Why : employeeabsence.INIT; ??? Do employeeabsence.RESET instead ?? No? And make filter : employeeabsence.SETRANGE(“Employee No.”,Empno); And if you would : Employeeabsence.SETFILTER(“From Date”,’…%1’,fromdt); Employeeabsence.SETFILTER(“To Date”,’%1…’,todt); I think, it’s “more navision like” … IF employeeabsence.FIND('-') THEN BEGIN REPEAT IF (fromdt>=employeeabsence."From Date") AND (todt<=employeeabsence."To Date") AND (Empno=employeeabsence."Employee No.")THEN BEGIN "Leave approved":="Leave approved"+1; END; UNTIL employeeabsence.NEXT=0; END;
reset; setfilter - fromdate; setfilter - todate; setfilter - empno; IF find first then repeat loop – cheers
Hi I hope this helps EmployeeAbsence.reset EmployeeAbsense.setfilter( “From Date”, ‘<=%1’, fromdt ); EmployeeAbsense.setfilter( “To Date”, ‘>=%1’, todate ); LeaveApproved := EmployeeAbsence.count; Regards Jyotsna
Oooops I applied filters wrongly it should be setfilter( “From Date”, ‘>=%1’, fromdt ); setfilter( “To Date”, ‘<=%1’, todt ); regards Jyotsna
Hi, still not able to find a solution.Let me give a clear picture. We have two tables “Employee absences” and “Attendance”.The fields that comes under the table “Employee absences” are Employee No.,From Date,To Date,Quantity and so on…Similarly Empno,Empname,No. of days present,No. of days absent,Leave approved,Nopay days,fromdt(leave taken from),todt(leave taken upto)form the table “Attendance”.Will be getting the CSV file which will have the datas for the fields Empno,Empname,No. of days present,No. of days absent,fromdt(leave taken from),todt(leave taken upto) and it has to be imported to the “Attendance” table.Now comes the calculation part, Leave approved is to be calculated by getting the values from the quantity field(no of leaves taken)of “Employee absences” table. Also Nopay days is to be calculated. so,the only left out thing is calculation part.Please help me out in this context with some codings. Best regards, Hari.
Hi there, Does this mean that you are using flowfields on your form? If so, I suggest to use the CALCFIELDS()-function. Example: CALCFIELDS(YourFieldName); HTH
Hari Which trigger on the form have you written the code[?] BTW Should “Leave Approved” := “Leave Approved” + Employeeabsence.Quantity;[?]
Hi, fromdt:=employeeabsence.“From Date” will fetch the values from the field “From Date” of the table “Employee Absences” and put the fetched values on the form pointing to the field “fromdt”.If so, it is not happening. Iam totally confused. Best Regards, Hari.
Hi stephen, The code is written on the OnActivateform trigger. Best Regards Hari.
Hari Try moving the code to the OnAfterGetRecord or the OnAfterGetCurrRecord trigger.