# Relationship based on variable

**URL:** <https://forum.servoy.com/t/relationship-based-on-variable/2737>\
**Category:** Classic Servoy\
**Created:** [September 21, 2004, 1:39pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737 "2004-09-21T13:39:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [September 21, 2004, 1:39pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/1 "2004-09-21T13:39:33Z")

</div>

Maybe it’s a bit of a newbie question and also very impossible, but is it possible to create a relationship based on a variable? ![:?:]( "Question")

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 21, 2004, 1:43pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/2 "2004-09-21T13:43:58Z")

</div>

It is possible to create a relation based on a global, which you can have acces on, on every form, alsco called: global relations.

Hope this helps

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [September 21, 2004, 2:39pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/3 "2004-09-21T14:39:35Z")

</div>

Thanks HJK, but I allready did that. It’s sometimes more handy to create a temporary relation in a method between variables, therefore my question…  
 ![:wink:]( "Wink")

---

<div class="post-metadata">

**Author:** ![Yeroc](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yeroc](https://forum.servoy.com/u/Yeroc)\
**Post date:** [May 14, 2010, 5:03pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/4 "2010-05-14T17:03:18Z")

</div>

Is there any chance this might change in the future? I was also wanting to define a relation on a form based on a form variable.

Thanks,  
Corey

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [May 14, 2010, 5:11pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/5 "2010-05-14T17:11:01Z")

</div>

> Yeroc:  
> Is there any chance this might change in the future?

Why would you think that ?  
I can’t look into the future but the fact that it’s been in the product for over 6 years makes it doubtful that they will (drastically) change it.

---

<div class="post-metadata">

**Author:** ![Yeroc](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yeroc](https://forum.servoy.com/u/Yeroc)\
**Post date:** [May 14, 2010, 6:54pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/6 "2010-05-14T18:54:57Z")

</div>

Sorry, I guess I mis-read the messages above and thus my question wasn’t clear. I was wondering if a future release might allow relations to be defined against a form variable rather than just a global variable. My reasoning behind preferring this in some situations is that the relation is only needed on a single form so it would be nice to avoid adding it as a global.

Corey

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [May 14, 2010, 7:06pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/7 "2010-05-14T19:06:39Z")

</div>

Hi Corey,

You can always file a feature request for this in Servoy’s [support system](http://www.servoy.com/s).

Do realize that a servoy relation based on a global is nothing more than a query with a filter, not a true join. It translates to “SELECT pk FROM table WHERE column = myGlobalValue”.  
So as a workaround you could do exactly that. Simply use SQL in the controller.loadRecords() like so :

```auto
var _sQuery = "SELECT pk FROM table WHERE column = ?";
forms.formInMyRelatedTabpanelButWithoutAnActualRelation.controller.loadRecords(_sQuery, [myFormGlobal]);

```

Assuming you want to load a form in a tabpanel that is ![:)]( "Smile") .

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Yeroc](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yeroc](https://forum.servoy.com/u/Yeroc)\
**Post date:** [May 17, 2010, 3:52pm UTC](https://forum.servoy.com/t/relationship-based-on-variable/2737/8 "2010-05-17T15:52:16Z")

</div>

Yes, that was my backup plan. Thanks.

Corey
