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!

CurrentUser() prob - Accessing queries using data access pages

Status
Not open for further replies.

neillovell

Programmer
Aug 27, 2002
560
GB
Hi,
Note: My database is on a network.
I have a form that accesses a query, which returns the rows from a table where LogonName equals the name of the user logged in to the database ( using CurrentUser() ). I saved the form as a data access page which works as I'd expect when you click on it directly (i.e. not running access), the messagebox appears asking for the user name and password to enter the database, however it does not understand CurrentUser().

The SQL statement that's causing the problems is
WHERE (((ADMINRecordsTable.LogOnName)=CurrentUser()) AND ((ADMINRecordsTable.Date) Between Date()-"14" And Date()));

NOTE: sorting the last few records by date is a new addition and is not the cause of the problem.

I am told that the "data provider failed when executing a provider command" and "CurrentUser() is an undefined function".
HOWEVER if I change CurrentUser() to something like 'neil-lovell' the data access page works perfectly. It just does not understand what CurrentUser() means for some reason. If I open the page from inside access (i.e. start up access rather than double clicking the data access page file) it works perfectly.

Has anyone encountered this?
 
I think the page is looking for exactly that, the current user. CurrentUser() may have been a function hidden in an include that sets the current session user information somewhere.

Try writing a small function like this.....

Function CurrentUSer()
CurrentUser='neil-lovell'
End Function

Then expand it out to get the current users' login information, either fomr a form based login or the local NTLM environment using ADSI.

JP _______________________________________________
OutsideIntranets.com
Stop wasting time, get to work
 
NTLM and ADSI? What are they?

Could be worth a shot. Are there any FAQs for form-based logons? The problem then of course would be that users have to log in twice to the system :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top