Solved

Getting Undefined Function error in MS Access

Posted on 2014-09-03
4
458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…

696 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