Solved

Getting Undefined Function error in MS Access

Posted on 2014-09-03
4
444 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 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