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!

Form opens to records only for specific user?

Status
Not open for further replies.

sara82

Technical User
May 20, 2005
78
US
I have a User Main Menu as seen below with the command buttons for New Work Log Entry and Edit Work Log Entry. The New Work Log entry opens a blank Work Log as shown below. The Work Log form's record source is tblWorkLog. The user will fill out all the fields except the End Page and Total Worked Pages. The user will then exit out of the database. When ready to enter the total worked pages the user log back in to the db and will click on the Edit Work Log Entry.
This is supposed to open up the last entry the current user was working on so that he or she can enter the End Page and Total Worked Pages
Currently it is opening up the last entry of the table even if it was a different user's.
How can I change this? I need it where it opens up the last record for that person. There are going to be 50 users so I can't have it open up to the last record of the table.
Any help will be apppreciated.

UserMenu.jpg

WorkLog.jpg
 
Are you saving the userid and datetime on the records?

If so then you need the final form to be based on a query which just fetches the top one record for that username, sorted by entrydate/time descending.
 
Yes in my table, tblWorkLog I have the fields for userid and logdate.

I do not have a field that stores both date and time for that record. Do I need to add that?

How would I create the query that you mention?

And it'll only show that user's last record no matter what? If I sign on as a different user and I click on Edit Work Log Entry it'll go to that user's last entry no the last entry of the table?
 
How are users logging in? Are they using the Access security login? If not how do you identify the user.

If the same user can create more than one record during the day then you need the time as well. If they don't then its not required.

The query would be something like:

Select top 1 * from mytable where Userid = <somevalue> order by logdate desc
 
Users are using Access security login. Yes the same user can create more than one record during the day.

So for the record source of the form I would have to put:

Select top 1 * from tblWorkLog where LogonID = <somevalue> order by logdate desc

What do I have to fill in for <somevalue>?
 
<somevalue> is a logon ID, which you can obtain with Environ("UserName") in VBA.

I would think you would use that to identify the person. You might need a table to look up the user's human name from their logon.



[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Ok I understand I can use CurrentUser()

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top