473,782 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Non-programmer needs help with VB code to locate file on hard drive

Long story short: My Access developer is letting me down. He doesn't
really know VB and he can't figure out how to do what I need.

Situation:
Access database that will be used locally on individual user's
machines.

What I need:
I need code to make Access look for a "security" file located on the
user's hard drive. If it finds the file, it allows the user to continue
into the application. If it doesn't find the file, the database shuts
down and does not let the user proceed.

I'm begging and pleading for help from all of you experts. I am not a
VB programmer, and I'm not so ignorant as to think I could teach myself
how to do this in the short time I have before I need to release this.

Is anyone willing to help me with this?

Nov 13 '05 #1
11 1926

"Wilsoch" <wi*****@comcas t.net> schreef in bericht news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Long story short: My Access developer is letting me down. He doesn't
really know VB and he can't figure out how to do what I need.

Situation:
Access database that will be used locally on individual user's
machines.

What I need:
I need code to make Access look for a "security" file located on the
user's hard drive. If it finds the file, it allows the user to continue
into the application. If it doesn't find the file, the database shuts
down and does not let the user proceed.

I'm begging and pleading for help from all of you experts. I am not a
VB programmer, and I'm not so ignorant as to think I could teach myself
how to do this in the short time I have before I need to release this.

Is anyone willing to help me with this?


I guess something like the following will do what you want:

If Len(Dir("path to secure file")) > 0 then
let user in
else
Docmd.Quit
end if

Arno R
Nov 13 '05 #2
Searching the whole hard drive could take quite a long time. If you
know where the file should be (full path), checking for its existence
would be almost instantaneous.
If we must search there are several ways to do so, including recursive
calls to Dir() [not so efficient], the File System Object, The Shell
etc. If you tell us the least versions of Access and of Windows within
which this code must run then we may be able to suggest the most
efficient way that will work there.

I'm assuming you have a good reason to have a relationship with this
particuar Access Developer (works for free? is your spouse? only one
available on desert is? and or something such?).

Nothing I have said should be construed to indicate that I think your
method of protecting your work is likely to be effective.

Nov 13 '05 #3
Yes, I realize this isn't the greatest way of doing this. I'm open to
other suggestions. The only pre-requisite is that the database will be
located on the user's hard drive (it won't be posted to a shared server,
etc.).

And yes, there's a "relationsh ip" with the developer in that I was
basically forced to use him.

The lowest versions should be as follows:
Windows 2000 and Access 2000

Those should be few and far between, though, and I would have no problem
requiring users to upgrade to Access 2003.

And yes, I have the full path to the file; it won't have to search the
whole hard drive.

Thank you for your response.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #4
Wilsoch wrote:
Long story short: My Access developer is letting me down. He doesn't
really know VB and he can't figure out how to do what I need.

Situation:
Access database that will be used locally on individual user's
machines.

What I need:
I need code to make Access look for a "security" file located on the
user's hard drive. If it finds the file, it allows the user to continue
into the application. If it doesn't find the file, the database shuts
down and does not let the user proceed.

I'm begging and pleading for help from all of you experts. I am not a
VB programmer, and I'm not so ignorant as to think I could teach myself
how to do this in the short time I have before I need to release this.

Is anyone willing to help me with this?


Maybe you can find a decent Access programmer at a nearby Access User's
Group.

See:

http://www.granite.ab.ca/access/usergroups.htm

You can also try something like monster.com. I suspect that some
experts posting here are not fully employed so maybe they will email
you privately. Many years ago a developer who owned a software company
in Texas suggested that hiring students was, in his experience, not a
great idea in spite of the hourly savings so I won't mention trying a
local university.

James A. Fortune

apophasis uh-PAH-fuh-sis noun : the raising of an issue by claiming
not to mention it. -- www.m-w.com

Nov 13 '05 #5
Yes, I realize this isn't the greatest way of doing this. I'm open to
other suggestions. The only pre-requisite is that the database will be
located on the user's hard drive (it won't be posted to a shared
server,
etc.).
And yes, there's a "relationsh ip" with the developer in that I was
basically forced to use him.
The lowest versions should be as follows:
Windows 2000 and Access 2000
Those should be few and far between, though, and I would have no
problem
requiring users to upgrade to Access 2003.
And yes, I have the full path to the file; it won't have to search the
whole hard drive.
Thank you for your response.

Nov 13 '05 #6
Under the condtions you describe this function should work:

Public Function DoesFileExist(B yVal FilePath As String) As Boolean
With WizHook
.Key = 51488399
DoesFileExist = .FileExists(Fil ePath)
End With
End Function

Please, understand that Wizhook is a hidden, undocumented object first
appearing in Access 2000; many developers will not use it because of
this. I have used it successfully a few million times on a few hundred
machines; this may or may not mean that it will be reliable into the
forseeable future.
Of coure the wrapping is unnecessary; only
With WizHook
.Key = 51488399
DoesFileExist = .FileExists(Fil ePath)
End With
is required.

Nov 13 '05 #7
I really do appreciate your assistance. You cannot possibly know how
much.

Should I see if my developer can figure out where to put this code
(doubtful) or is it easy enough for me to stick it in?

I'd like to e-mail you an offering of thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #8
Upon reading the whole thread I think Arno's solution is superior to
mine.

Nov 13 '05 #9
"Arno R" <ar***********@ tiscali.nl> wrote

I guess something like the following will do what you want:

If Len(Dir("path to secure file")) > 0 then
let user in
else
Docmd.Quit
end if

Put Arno R's code as first thing in the Open Event for the Form you specify
to be automatically Opened... that is set in the Tools | Startup item on the
menu, and you should have what you need.

I would comment than an Access developer who is not very familiar with VBA
is, indeed, NOT an "Access Developer" but just another Access User. Even
most "power users" with whom I am familiar know enough VBA to accomplish
this task and would, at the very least, be searching newsgroups on their own
to get the answer.

I see nothing wrong with Lyle's solution, and can vouch that he "knows his
stuff" when it comes to Access, but I also agree that Arno R's solution is
somewhat simpler and only uses documented features. Unless there is code you
need to run on the "let the user in" case, you could reduce that to a single
If... Then... with no Else. If your Developer can't figure out how to modify
the code, post back here after you dismiss him/her.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2347
by: Kartic | last post by:
Hello, I downloaded the Win32 installer for Twisted 1.3.0, Python 2.3. The installer, when executed under my login, fails as it requires administrator rights to install (why they have it as a requirement, I don't understand). So I started the installer as the admin user. That too failed because I have a non-admin install of Python 2.3 on my machine and when I launch
1
6906
by: Markus Ernst | last post by:
Hi I wrote a function that "normalizes" strings for use in URLs in a UTF-8 encoded content administration application. After having removed the accents from latin characters I try to remove all non-word characters from the string: // PCRE syntax: $string = preg_replace("/(+)/", "-", $string);
4
5312
by: bwmiller16 | last post by:
Guys - I'm doing a database consistency check for a client and I find that they're building unique indexes for performance/query reasons where they could be using non-unique indexes. Note that these columns in the unique indexes are truly unique and don't constitute a collision hazard of any kind. Now, I personally wouldn't use unique where non-unique would do but I
32
4527
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
3
2492
by: Ivan | last post by:
Hi, how to filter out non-digit chars when user writes text to System.Windows.Forms.TextBox? Thanks, Iavmn
13
2952
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
0
1453
by: Wijnand Kroes | last post by:
Hi guys, I have a C#.NET client which sends SOAP requests to .Net webservices and non ..Net webservices. If I do not add a SOAP header a get a valid response from all webservices. If I do add a SOAP header a get a valid response from the .Net webservice but an error from the client when accessing a non .Net webservice. The non .Net webservices are created in VB6 and Java.
7
1539
by: siddhu | last post by:
Dear Experts, I have a question. I wrote the following code class A { public: void g(){}
6
6479
by: Fabian Wein | last post by:
Hi, is there a way to call a const function from non const function? I have a non-const List GetList(); and want my
3
4100
by: George2 | last post by:
Hello everyone, I am debugging MSDN code from, http://msdn2.microsoft.com/en-us/library/0eestyah(VS.80).aspx here is my output, 1>main.cpp
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.