ThisComponent returns null from within a Base form

I’m near certain I’m doing something wrong, it’s probably in the docs’ fine print but for the life of me I can’t figure it out.

I want to invoke ThisDocument.getURL() from within a Base form to get the current app’s full filepath so that I can then fetch an image in an underlying folder. Seems a fairly standard call, like:

strFilepath = ThisDocument.getURL()

But it returns nothing.

I created a macro with just that same statement within a msgbox call (just as troubleshooting), and if I call the macro from Base main window then it returns the full filepath as expected (as a URL). But if I call the macro from within a form (event), it returns nothing.

What am I missing?

(I feel like such a noob…)

P.S., I’m aware that I can accomplish this by just creating an Image Control linked to my table’s column that specifies the filename, but I wanted to do this explicitly with ThisComponent, based on a solution I saw elsewhere online/YouTube.

Hello - we all have brain freeze at times.
.
You are trying to access the URL of the Base file but you are on a form which has no URL. Instead use:

strFilepath = ThisDocument.Parent.getURL()

Edit:

This also will work from a form:

strFilepath = ThisDatabaseDocument.getURL()

See > ThisDatabaseDocument vs ThisComponent?

1 Like

Thanks so much, Ratslinger (again!). Makes a lot of sense now that I see it pointed out.