Results 1 to 7 of 7
  1. #1
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110

    Double click subform row to bring that record into form.

    I have a form, TimeCard that has a subform, TimeCardSub that is set to data sheet view. Is there a way to double click on a row in TimeCardSub and have that record populate TimeCard for editing?

    I've tried a double click event on one of the fields (ComboBox, Job) using the following code.

    Code:
    Private Sub cboJob_DblClick(Cancel As Integer)    DoCmd.OpenForm "TimeCard", , , "[JobID] = " & Me!JobID
        Me.FilterOn = False
    End Sub
    This does bring up the correct job but not always the right record.

    I'm looking to in some way modify this code or something different/better so I can just double click anywhere on the specific (Row) record in TimeCardSub and bring it up in TimeCard. Please let me know if you have a solution to my problem or a better way to achieve this.

    As a bonus I'm also looking for a way to filter or code TimeCardSub to show the most recent entry on the top rather than the bottom as a double check for the person entering the data. This way they'll be able to quickly look back at their entries. Thoughts?

    Thanks for looking.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    This does bring up the correct job but not always the right record.
    I use similar code in the actual form object (the subform). However, I do not understand why you are using Me.FilterOn = False.

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    If that code doesn't bring up the correct record, your wherecondition isn't correct. It should either refer to a different field that is unique to the record being clicked on, or include a second field to narrow down the result.

    As to the order, you can base the subform on a query that sorts descending, so the most recent record will be on top.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    Paul,

    Thanks for the suggestions. I took a closer look and it does come up with multiple records with the same Job Is there a way to just bring up one the one that is clicked on? I would also like it to only show in the form and not in the subform.

    As for the
    Code:
    Me.FilterOn = False
    That's a head scratcher. I'm sure I had a reason, but for now I'm not sure what it was.


    I like the idea of basing my subform off of a query, but have little to no experience with them. Could you point me in the right direction on how to do this as it sounds like exactly what I need.

    Thanks for the quick responses and sorry I'm so slow getting to them.
    Attached Files Attached Files

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Like I said, use the field that uniquely identifies the record:

    DoCmd.OpenForm "TimeCard", , , "[ID] = " & Me!ID

    Instead of listing the table in the record source, try

    SELECT * FROM EmployeeWorkLog ORDER BY DateWorked DESC
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    Thank you so much. This works great!

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 07-22-2015, 03:45 AM
  2. Replies: 1
    Last Post: 07-14-2015, 05:59 AM
  3. Replies: 2
    Last Post: 10-29-2014, 03:25 AM
  4. Replies: 10
    Last Post: 02-20-2012, 11:25 AM
  5. On Double Click go to Subform
    By Theremin_Ohio in forum Access
    Replies: 2
    Last Post: 03-30-2011, 08:03 AM

Tags for this Thread

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