PC Review


Reply
Thread Tools Rate Thread

Undefined function 'ENVIRON' in expression

 
 
l
Guest
Posts: n/a
 
      12th Jan 2007
Hi,
I have developed an Access application on my pc, where it works fine,
and then have tried it on another user's, but I get the following error
message: "Undefined function 'ENVIRON' in expression." I use this
statement in my SQL, and it has worked ok until now:
(Employees.userID)=(Environ("USERNAME"))

Would this have something to do with the library set up on the other
pc?

Thanks for any help you can provide,
Louis

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      12th Jan 2007
Louis:

At first glance one would suspect a References problem, but putting that
aside, the use of the Environ function is not recommended. If you search on
'environ' here you'll find plenty of threads on this with alternative API
call suggestions. Here's my own however:

''''module starts''''
Option Compare Database
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long


Public Function GetUser() As String

Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long

lngSize = 199
strBuffer = String$(200, 0)

lngRetVal = GetUserName(strBuffer, lngSize)

GetUser = Left$(strBuffer, lngSize - 1)

End Function
''''module ends''''

which you could call in the query with:

Employees.UserID = GetUser()

Or you might like to consider calling the GetUser function at start-up to
update a column in a single row/single column local table, then join that
table to the Employees table in the query.

Ken Sheridan
Stafford, England

"l" wrote:

> Hi,
> I have developed an Access application on my pc, where it works fine,
> and then have tried it on another user's, but I get the following error
> message: "Undefined function 'ENVIRON' in expression." I use this
> statement in my SQL, and it has worked ok until now:
> (Employees.userID)=(Environ("USERNAME"))
>
> Would this have something to do with the library set up on the other
> pc?
>
> Thanks for any help you can provide,
> Louis
>
>


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      12th Jan 2007
"l" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Hi,
> I have developed an Access application on my pc, where it works fine,
> and then have tried it on another user's, but I get the following
> error message: "Undefined function 'ENVIRON' in expression." I use
> this statement in my SQL, and it has worked ok until now:
> (Employees.userID)=(Environ("USERNAME"))
>
> Would this have something to do with the library set up on the other
> pc?
>
> Thanks for any help you can provide,
> Louis


My guess is that it's the operation of Jet sandbox mode, which may be
set differently on different PCs:

http://support.microsoft.com/kb/294698/en-us


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
missinglinq via AccessMonster.com
Guest
Posts: n/a
 
      13th Jan 2007
Also, Environ is only available in versions later than AC2000.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200701/1

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      13th Jan 2007
"missinglinq via AccessMonster.com" <u28780@uwe> wrote in message
news:6c319741fc4c8@uwe...
> Also, Environ is only available in versions later than AC2000.
>


Not so. It was in as long ago as Access 2.0 (I just looked it up in my
Access 2.0 documentation), and I suspect it may have been there from the
beginning.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)



 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      22nd Jan 2007
Ken,

I am trying to try this suggestion. I have put the code in its own
module, named GetUser, and then I've put the call in the query
(Employees.UserID = GetUser() ), but when I run the query I get
"Undefined function 'GetUser' in query".

Here is the SQL from the query:

SELECT DISTINCTROW Employees.EmployeeID, Employees.LastName,
Employees.FirstName
FROM Employees
WHERE ((Employees.EmployeeID)=GetUser())
ORDER BY Employees.LastName;


Any ideas are greatly appreciated. Thanks.

========================

Thanks,
Louis


Ken Sheridan wrote:
> Louis:
>
> At first glance one would suspect a References problem, but putting that
> aside, the use of the Environ function is not recommended. If you search on
> 'environ' here you'll find plenty of threads on this with alternative API
> call suggestions. Here's my own however:
>
> ''''module starts''''
> Option Compare Database
> Option Explicit
>
> Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
> lpBuffer As String, nSize As Long) As Long
>
>
> Public Function GetUser() As String
>
> Dim strBuffer As String
> Dim lngSize As Long, lngRetVal As Long
>
> lngSize = 199
> strBuffer = String$(200, 0)
>
> lngRetVal = GetUserName(strBuffer, lngSize)
>
> GetUser = Left$(strBuffer, lngSize - 1)
>
> End Function
> ''''module ends''''
>
> which you could call in the query with:
>
> Employees.UserID = GetUser()
>
> Or you might like to consider calling the GetUser function at start-up to
> update a column in a single row/single column local table, then join that
> table to the Employees table in the query.
>
> Ken Sheridan
> Stafford, England
>
> "l" wrote:
>
> > Hi,
> > I have developed an Access application on my pc, where it works fine,
> > and then have tried it on another user's, but I get the following error
> > message: "Undefined function 'ENVIRON' in expression." I use this
> > statement in my SQL, and it has worked ok until now:
> > (Employees.userID)=(Environ("USERNAME"))
> >
> > Would this have something to do with the library set up on the other
> > pc?
> >
> > Thanks for any help you can provide,
> > Louis
> >
> >


 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      22nd Jan 2007

ll wrote:
> Ken,
>
> I am trying to try this suggestion. I have put the code in its own
> module, named GetUser, and then I've put the call in the query
> (Employees.UserID = GetUser() ), but when I run the query I get
> "Undefined function 'GetUser' in query".
>
> Here is the SQL from the query:
>
> SELECT DISTINCTROW Employees.EmployeeID, Employees.LastName,
> Employees.FirstName
> FROM Employees
> WHERE ((Employees.EmployeeID)=GetUser())
> ORDER BY Employees.LastName;
>
>
> Any ideas are greatly appreciated. Thanks.
>
> ========================
>
> Thanks,
> Louis
>
>
> Ken Sheridan wrote:
> > Louis:
> >
> > At first glance one would suspect a References problem, but putting that
> > aside, the use of the Environ function is not recommended. If you search on
> > 'environ' here you'll find plenty of threads on this with alternative API
> > call suggestions. Here's my own however:
> >
> > ''''module starts''''
> > Option Compare Database
> > Option Explicit
> >
> > Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
> > lpBuffer As String, nSize As Long) As Long
> >
> >
> > Public Function GetUser() As String
> >
> > Dim strBuffer As String
> > Dim lngSize As Long, lngRetVal As Long
> >
> > lngSize = 199
> > strBuffer = String$(200, 0)
> >
> > lngRetVal = GetUserName(strBuffer, lngSize)
> >
> > GetUser = Left$(strBuffer, lngSize - 1)
> >
> > End Function
> > ''''module ends''''
> >
> > which you could call in the query with:
> >
> > Employees.UserID = GetUser()
> >
> > Or you might like to consider calling the GetUser function at start-up to
> > update a column in a single row/single column local table, then join that
> > table to the Employees table in the query.
> >
> > Ken Sheridan
> > Stafford, England
> >
> > "l" wrote:
> >
> > > Hi,
> > > I have developed an Access application on my pc, where it works fine,
> > > and then have tried it on another user's, but I get the following error
> > > message: "Undefined function 'ENVIRON' in expression." I use this
> > > statement in my SQL, and it has worked ok until now:
> > > (Employees.userID)=(Environ("USERNAME"))
> > >
> > > Would this have something to do with the library set up on the other
> > > pc?
> > >
> > > Thanks for any help you can provide,
> > > Louis
> > >
> > >


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      22nd Jan 2007
You can't name the module the same as any of the routines within it.

Rename the module to, say, mdlGetUser.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"ll" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ken,
>
> I am trying to try this suggestion. I have put the code in its own
> module, named GetUser, and then I've put the call in the query
> (Employees.UserID = GetUser() ), but when I run the query I get
> "Undefined function 'GetUser' in query".
>
> Here is the SQL from the query:
>
> SELECT DISTINCTROW Employees.EmployeeID, Employees.LastName,
> Employees.FirstName
> FROM Employees
> WHERE ((Employees.EmployeeID)=GetUser())
> ORDER BY Employees.LastName;
>
>
> Any ideas are greatly appreciated. Thanks.
>
> ========================
>
> Thanks,
> Louis
>
>
> Ken Sheridan wrote:
>> Louis:
>>
>> At first glance one would suspect a References problem, but putting that
>> aside, the use of the Environ function is not recommended. If you search
>> on
>> 'environ' here you'll find plenty of threads on this with alternative API
>> call suggestions. Here's my own however:
>>
>> ''''module starts''''
>> Option Compare Database
>> Option Explicit
>>
>> Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
>> (ByVal _
>> lpBuffer As String, nSize As Long) As Long
>>
>>
>> Public Function GetUser() As String
>>
>> Dim strBuffer As String
>> Dim lngSize As Long, lngRetVal As Long
>>
>> lngSize = 199
>> strBuffer = String$(200, 0)
>>
>> lngRetVal = GetUserName(strBuffer, lngSize)
>>
>> GetUser = Left$(strBuffer, lngSize - 1)
>>
>> End Function
>> ''''module ends''''
>>
>> which you could call in the query with:
>>
>> Employees.UserID = GetUser()
>>
>> Or you might like to consider calling the GetUser function at start-up to
>> update a column in a single row/single column local table, then join that
>> table to the Employees table in the query.
>>
>> Ken Sheridan
>> Stafford, England
>>
>> "l" wrote:
>>
>> > Hi,
>> > I have developed an Access application on my pc, where it works fine,
>> > and then have tried it on another user's, but I get the following error
>> > message: "Undefined function 'ENVIRON' in expression." I use this
>> > statement in my SQL, and it has worked ok until now:
>> > (Employees.userID)=(Environ("USERNAME"))
>> >
>> > Would this have something to do with the library set up on the other
>> > pc?
>> >
>> > Thanks for any help you can provide,
>> > Louis
>> >
>> >

>



 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      22nd Jan 2007
Doug,
Thanks so much - that did the trick!

Louis


Douglas J. Steele wrote:
> You can't name the module the same as any of the routines within it.
>
> Rename the module to, say, mdlGetUser.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "ll" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Ken,
> >
> > I am trying to try this suggestion. I have put the code in its own
> > module, named GetUser, and then I've put the call in the query
> > (Employees.UserID = GetUser() ), but when I run the query I get
> > "Undefined function 'GetUser' in query".
> >
> > Here is the SQL from the query:
> >
> > SELECT DISTINCTROW Employees.EmployeeID, Employees.LastName,
> > Employees.FirstName
> > FROM Employees
> > WHERE ((Employees.EmployeeID)=GetUser())
> > ORDER BY Employees.LastName;
> >
> >
> > Any ideas are greatly appreciated. Thanks.
> >
> > ========================
> >
> > Thanks,
> > Louis
> >
> >
> > Ken Sheridan wrote:
> >> Louis:
> >>
> >> At first glance one would suspect a References problem, but putting that
> >> aside, the use of the Environ function is not recommended. If you search
> >> on
> >> 'environ' here you'll find plenty of threads on this with alternative API
> >> call suggestions. Here's my own however:
> >>
> >> ''''module starts''''
> >> Option Compare Database
> >> Option Explicit
> >>
> >> Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
> >> (ByVal _
> >> lpBuffer As String, nSize As Long) As Long
> >>
> >>
> >> Public Function GetUser() As String
> >>
> >> Dim strBuffer As String
> >> Dim lngSize As Long, lngRetVal As Long
> >>
> >> lngSize = 199
> >> strBuffer = String$(200, 0)
> >>
> >> lngRetVal = GetUserName(strBuffer, lngSize)
> >>
> >> GetUser = Left$(strBuffer, lngSize - 1)
> >>
> >> End Function
> >> ''''module ends''''
> >>
> >> which you could call in the query with:
> >>
> >> Employees.UserID = GetUser()
> >>
> >> Or you might like to consider calling the GetUser function at start-up to
> >> update a column in a single row/single column local table, then join that
> >> table to the Employees table in the query.
> >>
> >> Ken Sheridan
> >> Stafford, England
> >>
> >> "l" wrote:
> >>
> >> > Hi,
> >> > I have developed an Access application on my pc, where it works fine,
> >> > and then have tried it on another user's, but I get the following error
> >> > message: "Undefined function 'ENVIRON' in expression." I use this
> >> > statement in my SQL, and it has worked ok until now:
> >> > (Employees.userID)=(Environ("USERNAME"))
> >> >
> >> > Would this have something to do with the library set up on the other
> >> > pc?
> >> >
> >> > Thanks for any help you can provide,
> >> > Louis
> >> >
> >> >

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined function 'xxx' in expression - user function Topmark Microsoft Access 2 8th Oct 2008 05:16 PM
If 'undefined' then ... VS Try / Catch - how to trap 'undefined Rich Microsoft VB .NET 4 30th Sep 2008 05:33 PM
webpage error: "undefined" is undefined line 470 marc.peng@scotiabank.com Windows XP Internet Explorer 0 2nd Mar 2004 10:20 PM
Undefined function Left in expression Andy Microsoft Access 2 14th Jul 2003 07:59 PM
Undefined function 'Left' in expression Andy Microsoft Access 1 11th Jul 2003 06:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:12 AM.