Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Looking for an alternative to Access's Environ("username") for SQL Server.

I've just up-sized a .mdb application to a 2000 SQL server.  Everything worked great except I've used    Environ("username")   in several default and SQL queries.   Apparently SQL does not like Environ("username")  and I got ODBC errors.  I got around the default problem but I have not found a solution to include Environ("username") in a SQL query.  Any Ideas?

Cheers,
Worth
0
WorthN
Asked:
WorthN
1 Solution
 
thenelsonCommented:
Create a public function in a global module and call the function from within the query:
Public Function GetEnviron(EnvironCall As String)
   GetEnviron = Environ(EnvironCall)
End Function

Call with:
GetEnviron("UserName")
0
 
WorthNAuthor Commented:
That worked for the query, but is very slow for some reason when used on an access form.  Got better speed using a mix of the two.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now