We help IT Professionals succeed at work.

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

HIROYUKI TAMURA
HIROYUKI TAMURA used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

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

Commented:
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

Author

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

I tried in Query but did not work.

Author

Commented:
Snap430.png
MIS Liason
Most Valuable Expert 2012
Commented:
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:
https://support.office.com/en-gb/article/dir-function-1a1a4275-f92f-4ae4-8b87-41e4513bba2e
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...

JeffCoachman
Database7.accdb