Results 1 to 11 of 11
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Getting v.fraustrated - how do I get a last entry based on a perticular field?

    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

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Can you explain your scenario with a little more detail, please?

  3. #3
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    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

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    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.

  5. #5
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    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?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    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.

  7. #7
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    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

  8. #8
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    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.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    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.

  10. #10
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    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] ")

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Limit data entry based on another field
    By chemengr in forum Forms
    Replies: 5
    Last Post: 01-02-2014, 01:21 PM
  2. Need Help Creating Report Based on User Entry
    By italianfinancier in forum Programming
    Replies: 17
    Last Post: 05-27-2011, 04:58 AM
  3. Replies: 4
    Last Post: 04-18-2011, 07:18 AM
  4. Update value based on entry in another record
    By sparlaman in forum Programming
    Replies: 5
    Last Post: 04-04-2011, 04:10 PM
  5. Create a new entry based on old one
    By Alexandre Cote in forum Programming
    Replies: 3
    Last Post: 10-17-2010, 05:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums