Results 1 to 3 of 3
  1. #1
    Pbear88 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    26

    Selecting a record from a subform to display on the mainform

    Hello,

    I have a mainform (DrForm)that displays all the details of a given record. I also have a subform (DrHistory)with in this mainform that displays a quick, table style of those same records, but only shows a couple fields. When I click on the subform record, I want the mainform to display the corresponding record details in the mainform. Since both form and subform are from the same recordset, they both have the "DR_ID" field. I'm sure this is done quite often and I've looked at quite a few examples, but I can't seem to get it to work. Should I be using the GoToRecord command or the RecordsetClone command? In my mind, it should be as easy as telling Access- "When I click on this record, take the DR_ID field from this record in the subform, and now go to that same DR_ID record in the mainform." I'm just having trouble with the syntax.

    Thanks for any help you can supply.
    Andy

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If you upgrade to Access 2007, there is an intrinsic form object that automatically provides that capability. It is called a Split form.

    What code have you attempted?

    Suggest code that sets the Filter and FilterOn properties of main form.

    Me.Filter = Me.subform.DR_ID
    Me.FilterOn = True
    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
    Pbear88 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    26
    Thank you for your quick reply, and thank you for the information on Split forms. That will come in very useful, when I have to redesign most of these forms when we upgrade.

    I found another post that actually helped a lot. Here is what ended up working. "DoctorsForm" is the name of the mainform and this code was placed in the Subform properties.

    Private Sub Form_Click()
    Dim rs As Object
    Dim strLinkValue As String

    strLinkValue = Me![DR_ID].Value

    Set rs = Forms!DoctorsForm.Recordset.Clone
    Rs.FindFist "[DR_ID] = " & strLinkValue & ""



    Forms!DoctorsForm.Bookmark = rs.Bookmark


    End Sub


    Thank you again for your reply and help!

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

Similar Threads

  1. Replies: 2
    Last Post: 05-09-2017, 12:14 PM
  2. Replies: 4
    Last Post: 04-11-2016, 03:08 PM
  3. Replies: 7
    Last Post: 04-15-2014, 01:15 PM
  4. Replies: 7
    Last Post: 06-24-2013, 05:43 PM
  5. Selecting record in subform
    By survivo01 in forum Forms
    Replies: 8
    Last Post: 10-29-2012, 08:30 AM

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