Solved

VB.Environ Can't find project or library

Posted on 2011-03-17
6
1,126 Views
Last Modified: 2012-06-21
Hi. I am getting the following error in the Access VBA code below
"Can't find project or library"

    MYDOC_DIR = VBA.Environ("userprofile") & "\my documents"
 
0
Comment
Question by:murbro
6 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 35155186
Try MYDOC_DIR = Environ("userprofile") & "\my documents"
0
 

Author Comment

by:murbro
ID: 35155218
already tried that. Put the VBA on originally and the error went away
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 167 total points
ID: 35156396
FWIW remember that many users/network admins will change the name and/or location of the My Documents folder.

So you may not want to Hardcode this...
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 17

Assisted Solution

by:JezWalters
JezWalters earned 166 total points
ID: 35156397
It might be worth decompiling the database (taking a backup first) by running the following command:

    msaccess /decompile "<insert the full path to your database here>"

... and then recompiling the database again.
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 167 total points
ID: 35159287
This is what I get on my system:

?VBA.Environ("userprofile")
C:\Documents and Settings\Administrator

mx
0
 

Author Closing Comment

by:murbro
ID: 35166731
thanks for the help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now