Results 1 to 6 of 6
  1. #1
    HelenM is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    7

    Selecting record for form based on a selection from a sub form

    Hi,



    I have a form that is mainly used for data entry. It records fishing records for members in a club.

    The user asked me for a list of dates in the last 30 days when that member has fished, which I have done as a linked subform. However he now want to be able to go to any of those records, to check them. I can't work out how to get the main form to move to a record based on the member number and date (which will be unique) from a sub form. I've looked displaying the record number so that he can search for it in the bar at the bottom, and at moving to the record, but I can't work out how to get the main form to move to the required record. I've researched bookmark and goto record, but I'm stuck. Any advice welcome - thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Main form and subform have same data source? Have you considered a split form?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Try to put code in the Current event of the subform (which gets triggered when the user selects the record) to navigate the main form to that ID using recordset bookmark method or simply :

    Code:
    Me.Parent.Form![RecordID].SetFocus
    Docmd.FindRecord Me.RecordID 'the Me.RecordID is the control on the subform holding the uniqueID
    https://docs.microsoft.com/en-us/off...cmd.findrecord
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    To me, it sounds like there might be a design issue.

    If you have a form "MainForm" and you click a button to open another form (or have some method to open a 2nd form), the 2nd form is NOT a subform. It is just another form.
    If you have a form "MainForm" and you ADDed a subform CONTROL (like you would add a combo box control) that holds another form, then you have a subform. The subform control holds the 2nd form - NOW you have a main form/sub form design.


    How many tables do you have? I would think you would have at least 2 tables - a members table and a fishing table. And possibly a location table (where the member fished - Big Lake, The Pier, Minnow Pond,....)

    It would help if we knew more about your dB design.......

  5. #5
    HelenM is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    7

    Thumbs up This worked - thank you

    Quote Originally Posted by Gicu View Post
    Try to put code in the Current event of the subform (which gets triggered when the user selects the record) to navigate the main form to that ID using recordset bookmark method or simply :

    Code:
    Me.Parent.Form![RecordID].SetFocus
    Docmd.FindRecord Me.RecordID 'the Me.RecordID is the control on the subform holding the uniqueID
    https://docs.microsoft.com/en-us/off...cmd.findrecord
    Cheers,
    With a small tweak this worked thank you. The data is fully relational and the form is a sub-form, I just expressed myself badly. Because the form is set as continuous, as it lists all the fishing dates in the last 30 days, I put the code in the on-click event of the date listed in the sub form. I also had to make visible the control that holds the unique ID on the main form before I could setfocus in order to findrecord. I got around this by hiding it behind the sub-form.

    Thanks again

    H

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    You're welcome Helen!
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 3
    Last Post: 11-22-2015, 11:01 AM
  2. Replies: 3
    Last Post: 04-10-2015, 10:26 PM
  3. Replies: 7
    Last Post: 09-24-2013, 06:01 PM
  4. Replies: 4
    Last Post: 05-29-2013, 01:29 AM
  5. Replies: 9
    Last Post: 09-16-2011, 03:52 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