Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query works using Windows NT 4.0 but not Windows 2000?? 2

Status
Not open for further replies.

JonWolgamuth

Technical User
Apr 19, 2001
53
US
I have the following query to accommodate a multi-user setup and assign work.

SELECT entity_discrepancy.RowNumber, entity_discrepancy.FieldDiscrepancy, entity_discrepancy.TaxId, entity_discrepancy.TinType, entity_discrepancy.AmsSystemKey, entity_discrepancy.DmsSystemKey, entity_discrepancy.EqPSystemKey, entity_discrepancy.PaisSystemKey, entity_discrepancy.AmsValue, entity_discrepancy.DmsValue, entity_discrepancy.EqPValue, entity_discrepancy.PaisValue, entity_discrepancy.ChooseAms, entity_discrepancy.ChoosePais, entity_discrepancy.ChooseEqP, entity_discrepancy.ChooseDms, entity_discrepancy.FixedBy, entity_discrepancy.Done
FROM entity_discrepancy, User_tbl
WHERE (((entity_discrepancy.RowNumber)>=[LowerRange] And (entity_discrepancy.RowNumber)<=[UpperRange]) AND ((entity_discrepancy.Done)=No) AND ((entity_discrepancy.Research)=&quot;Research&quot;) AND ((User_tbl.UserID)=Environ(&quot;username&quot;)))
ORDER BY entity_discrepancy.FieldDiscrepancy, entity_discrepancy.TaxId;

When I run this query on my Windows NT box, it works no problem. However, the user area I wanted to distribute this to uses Windows 2000. When they try to run it they get an error which states &quot;This expression is typed incorrectly, or is too complicated to be evaluated.&quot;

Has anyone else come across such a predicament and found a good resolution?

Thanks in advance!

Jon
 
just as a test try removing the criteria
such as
>=[LowerRange] And <=[UpperRange]
and
Environ(&quot;username&quot;) <<<< Is this a function somewhere
And see if it runs.
If not, Save the query as something else and remove all criteria and the add one back at a time making sure it runs.

I suspect the function is not right somehow.

DougP, MCP
 
It's almost certainly going to be the Environ$(&quot;User&quot;) function that isn't working. If so let us know and I'll dig out another way of retrieving the user name.

One thing you could try - copy the SQL from behind the QueryDef and paste it into a new one. Sounds stupid I know, but it does sometimes work when you get this error.

Ed Metcalfe.

Please do not feed the trolls.....
 
I believe you both have identified the problem. Windows 2000 apparently does not recognize Environ(&quot;username&quot;).

Ed, is there a relatively simple way to get the username of a user on a Win2000 box?

Thanks to both of you!

Jon
 
This works in all versions of Windows I have tested it in:

Private Declare Function GetUserName Lib &quot;advapi32.dll&quot; Alias &quot;GetUserNameA&quot; (ByVal lpBuffer As String, nSize As Long) As Long

Public Function LogonID() As String
Dim strUserName As String
strUserName = String(8, Chr$(0))
GetUserName strUserName, 8
LogonID = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
End Function

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top