query with environement variable as criteria

DevAccess

Registered User.
Local time
Today, 12:47
Joined
Jun 27, 2016
Messages
321
hello there,

I would like to have query with criteria which should take input parameters/criteria from enviorment variable for example environ(username).

Is that possible ? so what would be the statement for that.


Thanks
 
in a module (not a form module) create a UDF something like

Code:
Function CurrentUser() as string
    CurrentUser=Environ("UserName")
End Function

then in your query use something like

SELECT *
FROM myTable
WHERE user=CurrentUser
 
Thanks but how to put this parameter in query designer I am not referring sql query here.
 
all the query designer is is a visual representation of the sql.

click on the sql button left of the ribbon or bottom right of the form and you will see the sql the designer has generated.

but to answer your question put 'currentuser' (no quotes) on the criteria line under the field you want to use it.
 
Thanks CJ IT IS JUST current user or environ(currentuser) in field criteria.
 

Users who are viewing this thread

Back
Top Bottom