# Table relation and LookupFormID

**URL:** <https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830>\
**Category:** Developers Forum\
**Created:** [March 29, 2005, 11:02am UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830 "2005-03-29T11:02:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![guidorobben](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@guidorobben](https://www.dynamicsuser.net/u/guidorobben)\
**Post date:** [March 29, 2005, 11:02am UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/1 "2005-03-29T11:02:12Z")

</div>

Hi, I have the following problem. I have a filed on the employee table (5200) named is Type. It’s a option filed containg Employee,Ex-Employee On a different table I have a filed linking to this table with the following table relation: Employee WHERE (Type=CONST(Employee)) So I only want to select the Employee’s that are real employees. The problem is that when I select the employee with the drownbutton, the lookupform of the 5200 is opened. Here it goes wrong. The cursor is not on the correct employee. It’s on the first employee. I found out that I created a Key that looks like this “Type, No.”. So when the form is opened, for some reason it selects that key and then it finds the first record. When I disable the key it works like it should. Does anybody have An idea how to solve this. I also solved the problem to select a view on the lookupform. But that’s not what i’m looking for. Guido

---

<div class="post-metadata">

**Author:** ![thomasbrodkorb](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@thomasbrodkorb](https://www.dynamicsuser.net/u/thomasbrodkorb)\
**Post date:** [March 29, 2005, 11:57am UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/2 "2005-03-29T11:57:45Z")

</div>

As a table relation always looks into the primary key fields, your foreign field should hold a Code20 field for the employee’s number and not an option field for the type. So there should not be a dropdown button available.

---

<div class="post-metadata">

**Author:** ![guidorobben](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@guidorobben](https://www.dynamicsuser.net/u/guidorobben)\
**Post date:** [March 29, 2005, 12:22pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/3 "2005-03-29T12:22:11Z")

</div>

There a 3 situations that resolve the problem but are no option. 1. Removing the where part. 2. I Have key that Navision selects that causes this problem. When I delete this key, everything works like it should. 3. If I set the SourceTableView to “No.” it also works. All the options above are no option. Is there another way?

---

<div class="post-metadata">

**Author:** ![thomasbrodkorb](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@thomasbrodkorb](https://www.dynamicsuser.net/u/thomasbrodkorb)\
**Post date:** [March 29, 2005, 1:04pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/4 "2005-03-29T13:04:30Z")

</div>

Why is 3 no option ?

---

<div class="post-metadata">

**Author:** ![Nelson](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@Nelson](https://www.dynamicsuser.net/u/Nelson)\
**Post date:** [March 29, 2005, 1:21pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/5 "2005-03-29T13:21:04Z")

</div>

Have you changed the Primary Key in Table 5200 Employee?

---

<div class="post-metadata">

**Author:** ![guidorobben](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@guidorobben](https://www.dynamicsuser.net/u/guidorobben)\
**Post date:** [March 29, 2005, 1:27pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/6 "2005-03-29T13:27:11Z")

</div>

I don’t want to stuck with that key. If I for some reason expand my where clause, navision will always use that key. But it should use a much faster key.

---

<div class="post-metadata">

**Author:** ![Nelson](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@Nelson](https://www.dynamicsuser.net/u/Nelson)\
**Post date:** [March 29, 2005, 1:35pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/7 "2005-03-29T13:35:42Z")

</div>

Can you please post the list of Keys you currently have in Table 5200 Employee.

---

<div class="post-metadata">

**Author:** ![guidorobben](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@guidorobben](https://www.dynamicsuser.net/u/guidorobben)\
**Post date:** [March 29, 2005, 1:50pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/8 "2005-03-29T13:50:18Z")

</div>

Enabled Key SumIndexFields yes No. yes Search Name yes Status,Union Code yes Status,Emplymt. Contract Code yes Status 2,Status,No. yes Birth Month,Birth Day yes Vendor No. This is the key that causes the problem yes Status 2,Status,No.

---

<div class="post-metadata">

**Author:** ![thomasbrodkorb](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@thomasbrodkorb](https://www.dynamicsuser.net/u/thomasbrodkorb)\
**Post date:** [March 29, 2005, 3:33pm UTC](https://www.dynamicsuser.net/t/table-relation-and-lookupformid/9830/9 "2005-03-29T15:33:38Z")

</div>

Navision uses the first key which contains the where clause fields. It does not use the “best” key. There is no way beside. except you write the onlookup code in the table yourself. As long as you do not have thousands of records in your employee table you will not really have a speed issue when running on the wrong key.
