# can't get the value from another table on the form

**URL:** https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475
**Category:** Developers Forum
**Created:** [August 19, 2003, 2:56pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475 "2003-08-19T14:56:18Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Hari](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hari](https://www.dynamicsuser.net/u/Hari)
#### Post date: [August 19, 2003, 2:56pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/1 "2003-08-19T14:56:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![marcipaci](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@marcipaci](https://www.dynamicsuser.net/u/marcipaci)
#### Post date: [August 19, 2003, 3:01pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/2 "2003-08-19T15:01:07Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hari](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hari](https://www.dynamicsuser.net/u/Hari)
#### Post date: [August 19, 2003, 3:47pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/3 "2003-08-19T15:47:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![geoffreyd78](https://avatars.discourse-cdn.com/v4/letter/g/3da27b/32.png) [@geoffreyd78](https://www.dynamicsuser.net/u/geoffreyd78)
#### Post date: [August 19, 2003, 4:16pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/4 "2003-08-19T16:16:40Z")

</div>

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;`

---

<div class="post-metadata">

### Author: ![Bobbysrivastava](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Bobbysrivastava](https://www.dynamicsuser.net/u/Bobbysrivastava)
#### Post date: [August 19, 2003, 5:31pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/5 "2003-08-19T17:31:48Z")

</div>

reset; setfilter - fromdate; setfilter - todate; setfilter - empno; IF find first then repeat loop – cheers

---

<div class="post-metadata">

### Author: ![jyotsnas](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jyotsnas](https://www.dynamicsuser.net/u/jyotsnas)
#### Post date: [August 20, 2003, 10:20am UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/6 "2003-08-20T10:20:34Z")

</div>

Hi I hope this helps EmployeeAbsence.reset EmployeeAbsense.setfilter( “From Date”, ‘\<=%1’, fromdt ); EmployeeAbsense.setfilter( “To Date”, ‘\>=%1’, todate ); LeaveApproved := EmployeeAbsence.count; Regards Jyotsna

---

<div class="post-metadata">

### Author: ![jyotsnas](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jyotsnas](https://www.dynamicsuser.net/u/jyotsnas)
#### Post date: [August 20, 2003, 10:22am UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/7 "2003-08-20T10:22:35Z")

</div>

Oooops I applied filters wrongly it should be setfilter( “From Date”, ‘\>=%1’, fromdt ); setfilter( “To Date”, ‘\<=%1’, todt ); regards Jyotsna

---

<div class="post-metadata">

### Author: ![Hari](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hari](https://www.dynamicsuser.net/u/Hari)
#### Post date: [August 20, 2003, 3:10pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/8 "2003-08-20T15:10:38Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![krop](https://avatars.discourse-cdn.com/v4/letter/k/48db29/32.png) [@krop](https://www.dynamicsuser.net/u/krop)
#### Post date: [August 20, 2003, 3:16pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/9 "2003-08-20T15:16:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![stepheng](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@stepheng](https://www.dynamicsuser.net/u/stepheng)
#### Post date: [August 20, 2003, 4:54pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/10 "2003-08-20T16:54:46Z")

</div>

Hari Which trigger on the form have you written the code[?] BTW Should “Leave Approved” := “Leave Approved” + Employeeabsence.Quantity;[?]

---

<div class="post-metadata">

### Author: ![Hari](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hari](https://www.dynamicsuser.net/u/Hari)
#### Post date: [August 20, 2003, 5:22pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/11 "2003-08-20T17:22:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hari](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hari](https://www.dynamicsuser.net/u/Hari)
#### Post date: [August 20, 2003, 5:55pm UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/12 "2003-08-20T17:55:54Z")

</div>

Hi stephen, The code is written on the OnActivateform trigger. Best Regards Hari.

---

<div class="post-metadata">

### Author: ![stepheng](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@stepheng](https://www.dynamicsuser.net/u/stepheng)
#### Post date: [August 21, 2003, 8:58am UTC](https://www.dynamicsuser.net/t/cant-get-the-value-from-another-table-on-the-form/7475/13 "2003-08-21T08:58:33Z")

</div>

Hari Try moving the code to the OnAfterGetRecord or the OnAfterGetCurrRecord trigger.
