# Syntax for use of db declared as public

**URL:** <https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235>\
**Category:** Getting Started\
**Created:** [May 10, 2026, 4:36pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235 "2026-05-10T16:36:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marvin\_Clavey](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@Marvin\_Clavey](https://forum.xojo.com/u/Marvin_Clavey)\
**Post date:** [May 10, 2026, 4:36pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/1 "2026-05-10T16:36:36Z")

</div>

![Screenshot From 2026-05-10 11-21-00](https://forum.xojo.com/uploads/default/original/3X/5/1/514610da875218591a967149eb1cdc3487f2d112.png)  
I cannot find the correct syntax to use a Public item  
I have tried app.db and also the use of ps as printer  
nothing I have tried works ☹  
They are both declared in the “APP” settings  
 ![Screenshot From 2026-05-10 11-28-25](https://forum.xojo.com/uploads/default/original/3X/0/8/08232e8437e4548602bcb7ceab63c419445709cb.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [May 10, 2026, 5:09pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/2 "2026-05-10T17:09:01Z")

</div>

App.whatever as long as they are public

---

<div class="post-metadata">

**Author:** ![Andrew\_Lambert](https://forum.xojo.com/user_avatar/forum.xojo.com/andrew_lambert/32/215_2.png) [@Andrew\_Lambert](https://forum.xojo.com/u/Andrew_Lambert)\
**Post date:** [May 10, 2026, 5:10pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/3 "2026-05-10T17:10:27Z")

</div>

To refer to properties of the `App` class, use the syntax `App.PropertyName`.

If you are already doing that but are getting a `NilObectException` when trying to use the property, be sure you are initializing it first with the `New` keyword:

```auto
App.db = New SQLiteDataBase // initialize first
App.db.SQLSelect(...) // then use

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [May 10, 2026, 5:14pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/4 "2026-05-10T17:14:18Z")

</div>

> [@Andrew\_Lambert](#):
>
> `NilObectException` when trying to use the property, be sure you are initializing it first with the `New` keyword:

Not every time.

You can do it in the app’s Opening event, or ‘just in time’, like this

`if App.db = nil then app.db = New SQLiteDataBase `_`// initialize if nil when you get here`_  
`App.db.SQLSelect(...) `_`// then use`_

---

<div class="post-metadata">

**Author:** ![Marvin\_Clavey](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@Marvin\_Clavey](https://forum.xojo.com/u/Marvin_Clavey)\
**Post date:** [May 10, 2026, 5:30pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/5 "2026-05-10T17:30:28Z")

</div>

Thanks very much .. I was using “as” when I should be using “=”

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [May 10, 2026, 6:10pm UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/6 "2026-05-10T18:10:47Z")

</div>

You can add a module and add your properties there.

Pro: No `App.` prefix  
Con: ?

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [May 11, 2026, 10:20am UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/7 "2026-05-11T10:20:59Z")

</div>

When creating App properties use Shared ones, they mare much faster to access. There can only be one either way so Shared is better. The same goes for App.methods.

---

<div class="post-metadata">

**Author:** ![Marvin\_Clavey](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@Marvin\_Clavey](https://forum.xojo.com/u/Marvin_Clavey)\
**Post date:** [May 12, 2026, 12:30am UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/8 "2026-05-12T00:30:38Z")

</div>

I do not understand “Shared” could you explain?

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [May 12, 2026, 6:38am UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/9 "2026-05-12T06:38:27Z")

</div>

![image](https://forum.xojo.com/uploads/default/original/3X/1/5/15694435b577a9fbd8bfadc8e26fad4358f60a5a.jpeg)

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [May 12, 2026, 8:54am UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/10 "2026-05-12T08:54:11Z")

</div>

If you define a class of your own you can have properties and methods. Each instance of the class has its own version of those items. So the code may look like this:

Var Elephant1, Elephant2 as New Elephant  
Elephant1.legs = 4  
Elephant2.legs = 3

The class can also have Shared Properties and methods. These exist only once and are accessed via the class name. No matter how many instances of the class you create there is only one of them. Code would look like this:

Elephant.NominalLegs = 4

Since there can only ever be one App object it makes no difference between shared and instance based properties. Shared are faster as Xojo does not need to obtain the instance reference to obtain the value. Yes a constant would make more sense in my example, but that doesn’t matter.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [May 12, 2026, 9:34am UTC](https://forum.xojo.com/t/syntax-for-use-of-db-declared-as-public/88235/11 "2026-05-12T09:34:10Z")

</div>

> [@Ian\_Kennedy](#):
>
> Since there can only ever be one App object it makes no difference between shared and instance based properties.

I have to say, at one time I had a whole bunch of properties at app level.

Changing them to shared properties got me a 5% speed increase at the time as I recall.

Worthwhile if they are accessed in a tight loop anywhere.
