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

Query With Environ Causing Errors 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.
 
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
 
PHV - you are an MVP!!!

I have been trying to get an answer on this for about a month, and you nailed it!

I don't understand why a month ago it worked, and then it didn't, but the bottom line is that it is fixed.

Thank you. Thank you. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top