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!

How to use Environ function in data access pages

Status
Not open for further replies.

paulfenwick

Technical User
Sep 16, 2004
20
GB
Hi, I'm trying to write a data access page that includes data related to the current logged on user. I have a combobox that pulls data from a query that uses the

Environ("username")

i.e. the query in SQL view is:
SELECT Personnel.Manager
FROM Personnel
WHERE (((Personnel.Initials)=Environ("username")));

function and saves this in a text field in the table. It all works fine when previewed in access but when opening the page in explorer, I get the error message "Data provider failed while executing a command" then "Unknown function name".

Is there another way to select records / info on a data access pages based on the current user?

I guessing I will need some VBA code in the page but I'm not very up on this
 
You may try something like this:
strUserName=CreateObject("WScript.Network").UserName
strSQL="SELECT Manager FROM Personnel WHERE Initials='" & strUserName & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Ph Thanks.

How would I include that code on the data access page or in the HTML code of the page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top