Undefined Function "Dir"

J

JohnB

HI.

I have a query which selects a field containing the path and image name for
an image. The field is called ImagePathAndFile and typically contains C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the image
name and was told to use Dir([ImagePathAndFile]) in a spare field in the
query. This works fine on my Access97 machine at home but produces an Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
D

Douglas J. Steele

I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that "Any
functions that do not appear in the list are not available in Sandbox mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnB said:
I have a query which selects a field containing the path and image name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
J

JohnB

Thanks to you both. I've checked the references - none are "missing" and the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding some
other library?

As for the registry, I'm afraid I know enough not to go poking around in
this, even if I could. This is a networked setup and I probably couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


Douglas J. Steele said:
I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that "Any
functions that do not appear in the list are not available in Sandbox mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnB said:
I have a query which selects a field containing the path and image name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
A

Allen Browne

Yes, you're right Doug.

I missed the important bit where JohnB said he is using this in the context
of a query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Douglas J. Steele said:
I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
References problem.

Details:
http://allenbrowne.com/ser-38.html

JohnB said:
I have a query which selects a field containing the path and image name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
D

Douglas J. Steele

Sorry, I don't have Access 2000 installed. In Access 2003, you have the
option of disabling sandbox mode when the macro security level is set to
Low.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JohnB said:
Thanks to you both. I've checked the references - none are "missing" and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding some
other library?

As for the registry, I'm afraid I know enough not to go poking around in
this, even if I could. This is a networked setup and I probably couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


Douglas J. Steele said:
I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in
the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
A

Allen Browne

John, there is something wrong here.

You said you are on Access 2000, but you are using the Access 10 object
library? Access 2000 should use the Access 9 library. If this is really the
case, you need to create a new (blank) database, turn off the Name
AutoCorrect setting (uncheck the boxes under Tools | Options | General), and
then import everything from the bad database.

If you are actually using Access 2002, then the Acc 10 library is correct.
You may need to get your IT people in to change the registry setting for
you. They should be able to do it based on that article.

Or you might be able to work around the issue by creating your own wrapper
function for Dir in a standard module, e.g.:
Function Dir2(PathName As String) As String
Dir2 = Dir(PathName)
End Function
and then use Dir2() in your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnB said:
Thanks to you both. I've checked the references - none are "missing" and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding some
other library?

As for the registry, I'm afraid I know enough not to go poking around in
this, even if I could. This is a networked setup and I probably couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


Douglas J. Steele said:
I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Allen Browne said:
References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in
the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
J

JohnB

Hi Allen.

Yes, you are correct, sorry for the confusion. My mdb is Access 2000, but is
running within Access 2002. i.e. if I open the mdb and look at "About Access"
it says Access 2000 but if I load Access without an mdb loaded, it says
Access 2002. Is there a problem with my using DAO 3.6 in this configuration?

I take your point about getting the network people to change the registry
but I'm also interested in your workaround. The trouble is, I'm not too hot
on Modules. Do you mean I should create a new Module and paste your code,
unchanged, into it? Is there a specific name (Dir2?) that I should give to
the module? Do I enter Dir2([PathAndFile]) in my query?

Thanks again for the help, JohnB


Allen Browne said:
John, there is something wrong here.

You said you are on Access 2000, but you are using the Access 10 object
library? Access 2000 should use the Access 9 library. If this is really the
case, you need to create a new (blank) database, turn off the Name
AutoCorrect setting (uncheck the boxes under Tools | Options | General), and
then import everything from the bad database.

If you are actually using Access 2002, then the Acc 10 library is correct.
You may need to get your IT people in to change the registry setting for
you. They should be able to do it based on that article.

Or you might be able to work around the issue by creating your own wrapper
function for Dir in a standard module, e.g.:
Function Dir2(PathName As String) As String
Dir2 = Dir(PathName)
End Function
and then use Dir2() in your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnB said:
Thanks to you both. I've checked the references - none are "missing" and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding some
other library?

As for the registry, I'm afraid I know enough not to go poking around in
this, even if I could. This is a networked setup and I probably couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


Douglas J. Steele said:
I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field in
the
query. This works fine on my Access97 machine at home but produces an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir' in
Expression".

Any idea why this is happening? Thanks, JohnB
 
D

Douglas J. Steele

The module MUST be named something other than the function(s) contained
within it.

Yes, copy the 3 lines of code Allen gave you into a new module, then save
it. My recommendation would be to name the module modDir2 or mdlDir2.

And yes again, you'd use the function in your query exactly as you've
indicated.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JohnB said:
Hi Allen.

Yes, you are correct, sorry for the confusion. My mdb is Access 2000, but
is
running within Access 2002. i.e. if I open the mdb and look at "About
Access"
it says Access 2000 but if I load Access without an mdb loaded, it says
Access 2002. Is there a problem with my using DAO 3.6 in this
configuration?

I take your point about getting the network people to change the registry
but I'm also interested in your workaround. The trouble is, I'm not too
hot
on Modules. Do you mean I should create a new Module and paste your code,
unchanged, into it? Is there a specific name (Dir2?) that I should give to
the module? Do I enter Dir2([PathAndFile]) in my query?

Thanks again for the help, JohnB


Allen Browne said:
John, there is something wrong here.

You said you are on Access 2000, but you are using the Access 10 object
library? Access 2000 should use the Access 9 library. If this is really
the
case, you need to create a new (blank) database, turn off the Name
AutoCorrect setting (uncheck the boxes under Tools | Options | General),
and
then import everything from the bad database.

If you are actually using Access 2002, then the Acc 10 library is
correct.
You may need to get your IT people in to change the registry setting for
you. They should be able to do it based on that article.

Or you might be able to work around the issue by creating your own
wrapper
function for Dir in a standard module, e.g.:
Function Dir2(PathName As String) As String
Dir2 = Dir(PathName)
End Function
and then use Dir2() in your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JohnB said:
Thanks to you both. I've checked the references - none are "missing"
and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding
some
other library?

As for the registry, I'm afraid I know enough not to go poking around
in
this, even if I could. This is a networked setup and I probably
couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


:

I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list
of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically
contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just
the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field
in
the
query. This works fine on my Access97 machine at home but produces
an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir'
in
Expression".

Any idea why this is happening? Thanks, JohnB
 
J

JohnB

Thanks Doug.

Unfortunately I cannot now get to the office mdb. But I have now done as
described on the Access 97 mdb here at home. This works fine, so it proves
that I now know what to do. Hopefully it will work also on the Access 2000
mdb at the office. I'll post on this thread, on Monday, either way.

Many thanks for the help, JohnB

Douglas J. Steele said:
The module MUST be named something other than the function(s) contained
within it.

Yes, copy the 3 lines of code Allen gave you into a new module, then save
it. My recommendation would be to name the module modDir2 or mdlDir2.

And yes again, you'd use the function in your query exactly as you've
indicated.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JohnB said:
Hi Allen.

Yes, you are correct, sorry for the confusion. My mdb is Access 2000, but
is
running within Access 2002. i.e. if I open the mdb and look at "About
Access"
it says Access 2000 but if I load Access without an mdb loaded, it says
Access 2002. Is there a problem with my using DAO 3.6 in this
configuration?

I take your point about getting the network people to change the registry
but I'm also interested in your workaround. The trouble is, I'm not too
hot
on Modules. Do you mean I should create a new Module and paste your code,
unchanged, into it? Is there a specific name (Dir2?) that I should give to
the module? Do I enter Dir2([PathAndFile]) in my query?

Thanks again for the help, JohnB


Allen Browne said:
John, there is something wrong here.

You said you are on Access 2000, but you are using the Access 10 object
library? Access 2000 should use the Access 9 library. If this is really
the
case, you need to create a new (blank) database, turn off the Name
AutoCorrect setting (uncheck the boxes under Tools | Options | General),
and
then import everything from the bad database.

If you are actually using Access 2002, then the Acc 10 library is
correct.
You may need to get your IT people in to change the registry setting for
you. They should be able to do it based on that article.

Or you might be able to work around the issue by creating your own
wrapper
function for Dir in a standard module, e.g.:
Function Dir2(PathName As String) As String
Dir2 = Dir(PathName)
End Function
and then use Dir2() in your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks to you both. I've checked the references - none are "missing"
and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding
some
other library?

As for the registry, I'm afraid I know enough not to go poking around
in
this, even if I could. This is a networked setup and I probably
couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


:

I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list
of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically
contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just
the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field
in
the
query. This works fine on my Access97 machine at home but produces
an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir'
in
Expression".

Any idea why this is happening? Thanks, JohnB
 
J

JohnB

Hi again Doug. I've just done this on my office mdb and it worked perfectly.
Thanks again, JohnB

Douglas J. Steele said:
The module MUST be named something other than the function(s) contained
within it.

Yes, copy the 3 lines of code Allen gave you into a new module, then save
it. My recommendation would be to name the module modDir2 or mdlDir2.

And yes again, you'd use the function in your query exactly as you've
indicated.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JohnB said:
Hi Allen.

Yes, you are correct, sorry for the confusion. My mdb is Access 2000, but
is
running within Access 2002. i.e. if I open the mdb and look at "About
Access"
it says Access 2000 but if I load Access without an mdb loaded, it says
Access 2002. Is there a problem with my using DAO 3.6 in this
configuration?

I take your point about getting the network people to change the registry
but I'm also interested in your workaround. The trouble is, I'm not too
hot
on Modules. Do you mean I should create a new Module and paste your code,
unchanged, into it? Is there a specific name (Dir2?) that I should give to
the module? Do I enter Dir2([PathAndFile]) in my query?

Thanks again for the help, JohnB


Allen Browne said:
John, there is something wrong here.

You said you are on Access 2000, but you are using the Access 10 object
library? Access 2000 should use the Access 9 library. If this is really
the
case, you need to create a new (blank) database, turn off the Name
AutoCorrect setting (uncheck the boxes under Tools | Options | General),
and
then import everything from the bad database.

If you are actually using Access 2002, then the Acc 10 library is
correct.
You may need to get your IT people in to change the registry setting for
you. They should be able to do it based on that article.

Or you might be able to work around the issue by creating your own
wrapper
function for Dir in a standard module, e.g.:
Function Dir2(PathName As String) As String
Dir2 = Dir(PathName)
End Function
and then use Dir2() in your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks to you both. I've checked the references - none are "missing"
and
the
following are checked:

Visual Basic For Aplications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library

I was advised to set my mdb to this through this newsgroup, when I was
having problems with some code a few months ago. Should I be adding
some
other library?

As for the registry, I'm afraid I know enough not to go poking around
in
this, even if I could. This is a networked setup and I probably
couldn't
modify the registry if I wanted to.

How do I proceed? Thanks, JohnB


:

I'm wondering if it could also be the Sandbox mode, Allen.

http://support.microsoft.com/?id=239482 doesn't list Dir in the list
of
functions in Jet queries when Sandbox mode is enabled, and states that
"Any
functions that do not appear in the list are not available in Sandbox
mode."

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



References problem.

Details:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


I have a query which selects a field containing the path and image
name
for
an image. The field is called ImagePathAndFile and typically
contains
C:\My
Pictures\Mvc0000.JPG.

I posted a question as to how to produce a field containing just
the
image
name and was told to use Dir([ImagePathAndFile]) in a spare field
in
the
query. This works fine on my Access97 machine at home but produces
an
Error
here in work, using Access 2000 on XP: "Undefined Function 'Dir'
in
Expression".

Any idea why this is happening? Thanks, JohnB
 
Top