# Do I need to access the Data table every time using its Dir-Reference?

**URL:** <https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, question, CPP\
**Created:** [April 28, 2022, 5:48pm UTC](https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365 "2022-04-28T17:48:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [April 28, 2022, 5:48pm UTC](https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365/1 "2022-04-28T17:48:11Z")

</div>

I created this logic and I am accessing the Data table Directory everytime to access its directory, so my Question is it not possible to access its rows using the already declared pointer to the data table called **row**

```auto
	if (_bCrouching)
	{
		if (!_bHoldWeapon && (MoveForwardAxis != 0.0f || MoveRightAxis != 0.0f))
		{

			//Get the Camera height row from data table of Camera Height Row and set the value to the new height from this.
			if (const UDataTable* DT_CameraHeight{ LoadObject<UDataTable>(GetWorld(), TEXT("DataTable'/Game/Blueprints/BP_DataTables/Camera/DT_CameraHeight.DT_CameraHeight'")) })
			{
				//Set camera height for crouch normal move
				if (const FST_CameraHeight* Row{ DT_CameraHeight->FindRow<FST_CameraHeight >("Crouch_Normal_Move", "") }) //60
				{
					_NewHeight = Row->Height;
					printf("The new value for NewHeight from Crouch_Normal_Move is: %f", _NewHeight);
				}
			}

			else
			{
				if (_bHoldWeapon && (MoveForwardAxis != 0.0f || MoveRightAxis != 0.0f))
				{

					//Get the Camera height row from data table of Camera Height Row and set the value to the new height from this.
					if (const UDataTable* DT_CameraHeight{ LoadObject<UDataTable>(GetWorld(), TEXT("DataTable'/Game/Blueprints/BP_DataTables/Camera/DT_CameraHeight.DT_CameraHeight'")) })
					{
						//Set camera height for crouch Rifle move
						if (const FST_CameraHeight* Row{ DT_CameraHeight->FindRow<FST_CameraHeight >("Crouch_Rifle_Move", "") }) //80
						{
							_NewHeight = Row->Height;
							printf("The new value for NewHeight from Crouch_Rifle_Move is: %f", _NewHeight);
						}
					}
				}
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [April 28, 2022, 5:51pm UTC](https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365/2 "2022-04-28T17:51:09Z")

</div>

> [@Alexa.Ki](#):
>
> `_NewHeight = Row->Height;`

you should be able to access any row under the data table using your pointer **someVariable = Row-\>Height;** if you are under the same loop I think. cheers

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [April 28, 2022, 6:02pm UTC](https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365/3 "2022-04-28T18:02:09Z")

</div>

Thank You, its working ) and what if I want to access it in other conditions outside of the loop?

---

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [April 28, 2022, 6:04pm UTC](https://forums.unrealengine.com/t/do-i-need-to-access-the-data-table-every-time-using-its-dir-reference/542365/4 "2022-04-28T18:04:29Z")

</div>

_const UDataTable DT\_CameraHeight{ \*\*\*\*\*\*\*\*\*\*\*\* };_\* Declare this line globally in the top of the function or create it as a global class to access it anywhere, you can also make a macro of it to access it easity. cheers
