Solved

Getting Undefined Function error in MS Access

Posted on 2014-09-03
4
452 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 - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 40301905
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
ID: 40301907
<<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
ID: 40302125
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
ID: 40302253
You are welcome .
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

861 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