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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environ Expression in a Query 1

Status
Not open for further replies.

jt643

Technical User
Jun 17, 2003
144
I have been working on an issue in thread705-1130455.

It now appears that the issue is not with the VB or References, but rather in my queries. In the VB, I define:

Dim UserID As String
UserID = Environ("USERNAME")

I then run queries that also have criteria of:

WHERE (((SelectionsTemp.UserID)=Environ("USERNAME")))

It seems to consistently be blowing up whenever I use a report or try to open a form that calls a query with similar criteria.

Again, it seems to be working fine on local machines, but on the Remote machine, it keeps giving me the error.

Does anyone have any ideas?

I need to keep the criteria as is in a couple situations because my queries join several tables, and I need to filter based on the UserID.
 
Cross post: Perhaps a problem with SandBox mode ?
Create the following function in a standard code module:
Code:
Public Function getWinUser() As String
getWinUser = Environ("UserName")
End Function

And now the criteria:
WHERE SelectionsTemp.UserID=getWinUser()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That's it! Thank you PHV. Please see my other comments at thread181-1130655.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top