Solved

Getting Undefined Function error in MS Access

Posted on 2014-09-03
4
411 Views
Last Modified: 2014-09-03
I have an MS Access 2010 application that I deploy as an accdr file along with Access 2010 runtime.
At startup in this application I need to determine if the application is being run by someone remotely on my Terminal Server.  The computer name of the terminal server is "RDS01"
The line of code to check this is as follows:

         If Environ("computername") = "RDS01" Then

When the application is run on any computer other than my Terminal Server the line executes properly, determining the name of the computer.
But, when the application is run on my Terminal Server this line of code fails with the following message:

      Undefined function 'Environ' in expression

Can someone tell me why this is happening?
0
Comment
Question by:dsoderstrom
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
Comment Utility
Is the DB in a Trusted Location ?
And meanwhile, I suggest you not use Environ() and instead use the standard Windows API call - which will not have this issue:

Get Computer Name
http://access.mvps.org/access/api/api0009.htm

mx
0
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<Can someone tell me why this is happening? >>

 More than likely, the bane of VBA code writers; a broken reference.

 VBA relies on a reference list (with the VBA editor open, tools/references).   If a reference is "bad", than the VBA project won't run.

 What you'll need to do is add code like that found here:

IsBroken Property [Access 2003 VBA Language Reference]
http://msdn.microsoft.com/en-us/library/office/aa196149%28v=office.11%29.aspx

 or get a full install of Access on there with a DB not in runtime mode.

 You also might be able to figure it out from the reference list.  Look for non-standard ones you may have used.   If your lucky, you haven't used them in the app and can un-check, compile, and save and you'll be set.

 If you have used something, you'll need to figure out how to get it installed for your app or a way not to use it.

Jim.
0
 

Author Closing Comment

by:dsoderstrom
Comment Utility
The Windows API call was exactly what I was looking for and if fixed the problem.
It also led me to another API call for determining the user login name which I was also using the environ function to retrieve.
Everything works perfectly now.  Thank You.
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
You are welcome .
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 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