473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dir function throws error when no access to file

I have an Access/Jet app with a ton of VBA, and a few particular funcitons are giving me trouble.

We have a part of this program where we can link a file name (with the full path) to an order. This works well most of the time. This gives us a record of what datafiles were used.

Recently, we had another department start using the Link function to link /their/ files on the network (original documents, design files, that sort of thing). The problem is that not everyone has at least read access to these files - and when the form loads and checks the file names, if the current user does not have access to that file, Dir throws a "Bad file name or number" error.

Does anyone have any solution to this aside from giving everyone read access to everything? The builtin Access non-help is about as helpful as usual - any suggestions?

~KJ
Nov 21 '07 #1
4 4029
ADezii
8,834 Expert 8TB
I have an Access/Jet app with a ton of VBA, and a few particular funcitons are giving me trouble.

We have a part of this program where we can link a file name (with the full path) to an order. This works well most of the time. This gives us a record of what datafiles were used.

Recently, we had another department start using the Link function to link /their/ files on the network (original documents, design files, that sort of thing). The problem is that not everyone has at least read access to these files - and when the form loads and checks the file names, if the current user does not have access to that file, Dir throws a "Bad file name or number" error.

Does anyone have any solution to this aside from giving everyone read access to everything? The builtin Access non-help is about as helpful as usual - any suggestions?

~KJ
What exactly are you looking for?
  1. A more descriptive Error Message?
  2. Resume program execution if the specific Error occurs?
  3. Stop Program execution?
  4. Aside from granting Read Access, I do believe you are sort of handcuffed.
Nov 22 '07 #2
What exactly are you looking for?
  1. A more descriptive Error Message?
  2. Resume program execution if the specific Error occurs?
  3. Stop Program execution?
  4. Aside from granting Read Access, I do believe you are sort of handcuffed.
I suppose that if we have to do either read access or continue running, security dictates that we continue running, suppressing error messages unless they try to open the file.

I was hoping someone had done a work around - like ghosting as a read-only user or something similar. The problem is that keeping the error messages is useful if the file doesn't actually exist - I was hoping to only suppress them if the file was not accessible. Which means that it might as well not exist.

Groan.
I hate "fixing" things by screwing with the error handling. It really makes me nervous.

Anyone else?
~KJ
Nov 27 '07 #3
ADezii
8,834 Expert 8TB
I suppose that if we have to do either read access or continue running, security dictates that we continue running, suppressing error messages unless they try to open the file.

I was hoping someone had done a work around - like ghosting as a read-only user or something similar. The problem is that keeping the error messages is useful if the file doesn't actually exist - I was hoping to only suppress them if the file was not accessible. Which means that it might as well not exist.

Groan.
I hate "fixing" things by screwing with the error handling. It really makes me nervous.

Anyone else?
~KJ
If a File does not exist, or it does exist and the Path to it is incorrect, the Dir() Function will return a Zero Length String. If the File is not accessible, Error Number 52 will be generated - Bad file name or number. Why can't you simply set an Error Trap for Error Number 52, then suppress any Error Message. If the File doesn't exist, simply check for a return value from Dir() of a Zero Length String, then display an Error Message. Will this work in your current situation?
Nov 27 '07 #4
Ahhhh... I thought the error was generated anytime the file couldn't be accessed through the given path, whether it be due to permissions or bad typing. Perhaps I need to check our code again - I apparently was mistaken.

Yes, that helps considerably.

Thank you!
~KJ
Nov 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
8
by: Falc2199 | last post by:
Hi, Does anyone know how to make this work? var sectionId = 5; repeat_section_sectionId(); function repeat_section_5(){ alert("firing"); }
7
by: C.E.O. Gargantua | last post by:
I am using the IBM DB2 Connector class of the Redistributable DB2 Run-Time Client Lite in a c# .net application using Visual Studio. Running the code: string myConnString =...
3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
8
by: Lauren Wilson | last post by:
Hi Folks, We have a solid, five year old Access app that is suddenly behaving oddly after conversion to Access 2002/2003 format. Everything seems to run OK except for a few oddities. The code...
2
by: jay | last post by:
I am attempting to impersonate an account in ASPNET. I am using aspnet_setreg to store the username and passwords. I have given the ASPNET account permisision to read the registry values. However,...
28
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't...
9
by: Matt | last post by:
Hi friends, Okay so well, I have quite a problem right now with a file stream. What I am doing is to use the Cannon SDK dlls to get control over my old Cannon A60 Camera for some surveillance...
2
by: sbasavar | last post by:
Hi All, In my excel programming, I am using XML http object (MSXML2.XMLHTTP.3.0). Using this object when I try to send a request application throws an "Access is Denied" error. Strange thing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.