We help IT Professionals succeed at work.

MS Access Questions how to create a field shows if a path exits

HIROYUKI TAMURA used Ask the Experts™
I would like to create a conditional field where shows if a folder exists on a path contains in a field, put true value i other field in MS Access form.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer

You can use

=Iif(Len(Dir([YourDirectoryColumn], vbDirectory)), "Exists", "Nope")

Open in new window

or returning a boolean

=Len(Dir([YourDirectoryColumn], vbDirectory)) > 0

Open in new window


Thank you, ste5an
Would you teach me how to implement the code?

I tried in Query but did not work.


MIS Liason
Most Valuable Expert 2012
Despite your question's brevity, ...there is a lot we don't know.
For example:
1. You never stated what was not working for you.  You only stated: "I tried in Query but did not work. "
    ...not working in what way?,  ...What did or did not happen when you tried it?
2. Is the "Other Field" and actual Field (in the table) or just a textbox on the form?
3. Is the full path and folder in the main field, ...or is the path in one field and the folder name in another?
4. Do you want just the text "True" or "False" displayed,...or do you want the actual Boolean value returned?

In any event, ...the expression (Dir) may have failed because of a registry issue:
from here:
Note: The function, method, object, or property described in this topic is disabled if the Microsoft Jet Expression Service is running in sandbox mode, which prevents the evaluation of potentially unsafe expressions. For more information on sandbox mode, search for "sandbox mode" in Help.

So you may have to use a VBA wrapper function.

Here is a basic sample using a query, ...just to show you that this works.
(Please examine the table, query and the form)
See if you can apply the same principles to your database. If not, then check back in with us...