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!

Control Default Value to Equal Query Result Version: 2003 (11.0)

Status
Not open for further replies.

rmtiptoes

IS-IT--Management
Mar 30, 2004
55
US
I have a form with a user text box that I want to default to the current user logged into the application. I track the latest user in a separate table so this info is updated. After the user logs on, he/she opens forms with a user field that should default to the following sequel:

SELECT tblUserSecurity.UserID FROM tblUserSecurity WHERE tblUserSecurity.lastsignon = (SELECT MAX(tblUserSecurity.lastsignon)FROM tblUserSecurity);

When I add this query or a macro or Expression based upon this query, I receive the following error when the user creates a new record:

#Error

What am I doing wrong here?

Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
Have you tried something like this ?
=DLookUp("UserId", "tblUserSecurity", "lastsignon=" & DMax("lastsignon", "tblUserSecurity"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you for the response. I am still getting the error. If I try the statements seperately I obtain the componenents, but nested I get the error.

Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
I actually found something on this site that works for my CurrentUser query! Check it out

=DLookUp("userID","[CurrentUser]")

Thanks again for your help!




Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top