Hey all.....
Honestly I am trying, I googled forum'd etc etc but I cant get my chuffin head around it. How do I get the last entry made based on a username field? Then pull that date to a textbox?
Answers/help/guidence will be appreciated - thanks
Hey all.....
Honestly I am trying, I googled forum'd etc etc but I cant get my chuffin head around it. How do I get the last entry made based on a username field? Then pull that date to a textbox?
Answers/help/guidence will be appreciated - thanks
Can you explain your scenario with a little more detail, please?
Ok so as you can see from here http://imgur.com/98O0e my table displays the username and the time/date the record was submitted. Im trying to display that in a text box. But the username should be dependant on who is the current user at the time, so it only shows thier records. Does this make sense? Thanks
Do you already have a Form set up for this?
How does your user GET to the Form?
How do you intend for the Form to 'know' who the user is?
Since you haven't described the exact scenario in detail - it is difficult to help.
Here's a page that I've looked at a few times and found very helpful:
http://www.baldyweb.com/wherecondition.htm
You might find some answers there.
Here's another helpful site:
http://allenbrowne.com/tips.html
What I 'THINK' you may be trying to do - sounds like a pretty simple process.
BUT -
you have to describe what you want in very specific detail - or it is difficult for people to help.
I guess I assume Im making myself clear as it sounds ok in my head rather than telling exactly what I mean - sorry.
Ok so the user launches the form - there is only 1. It gets the logged in current user using some code and populates a text box with this info - have this working. I was thinking the query or what ever does the funky bit which works out the last date submitted via the username queries the username (current logged in user) to know which record it should be looking for - Im not sure just a guess?
You want to open form to last record associated with this user? There is a field in table that has user names? Assuming the form RecordSource is ordered ascending by date, maybe:
Me.FilterOn = False
Me.Filter = "username='" & Me.textboxname & "'"
Me.FilterOn = True
DoCmd.GoToRecord acDataForm, Me.Name, acLast
If ordered descending by date, don't need the GoToRecord.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Sorry June, Ive just read what I put previously I dont know how you got to your suggestion from what I put but anyway. So heres a screen grab of the form as you can see it captures the logged in user http://i.imgur.com/EgQA8.png
When they user submits the form with all the bits its looks like this
http://i.imgur.com/98O0e.png
As you can see Administrator has submitted 2 entries 1 on the 31/12/1899 and another on 01/01/1900 what the box on the first image should display based on the logged in user and the dates in the table is 01/01/1900 as this is the most recent entry all be it 111 years ago
If you just upload your screenprint here (on this website) then more people can see it since many other sites are blocked by my workplace and possibly for others as well.
You said you were looking for a record, not a single value, that is what led to my previous suggestion.
Date Last Submitted is an unbound textbox? Assuming last date submitted means the most recent date, try in the textbox ControlSource:
=DMax("[Task Date]", "TimesheetTable", "sUser='" & UserTextbox & "'")
How are you saving the TaskDate that ends up with bizarre date value?
BTW, should avoid spaces, special characters, punctuation (underscore is exception) in names, otherwise must remember to enclose in [].
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Sorry, I need to learn all the different terminologies as I say one thing which means something different. Anyway... I made a bit of a mistake I stated the wrong date I meant I wanted the time_of_submittion. Ive added the above suggestion. But on a bonus its working so thanks a million!!! This is what I used
Code:DMax("[TimesheetTable]![Time_Of_Submission] ", "TimesheetTable", " [LoggedInUser] ")
Actually, that should not work. The WHERE argument is incomplete.
DMax("[Time_Of_Submission]", "TimesheetTable", "sUser='" & [LoggedInUser] & "'")
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.