Results 1 to 3 of 3
  1. #1
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314

    Move a record in a subform to the parent form

    I have a main form called Assets, which shows one Asset at a time, and two continuous subforms.


    The second subform is called Asset_Groups. Its purpose to to show all other assets which share the same Group value as the active record in the Parent form.

    The Asset_Groups form uses the same table as the main form. Its Parent and Child fields are both set to Group. As I move from one Asset to another in the parent form, the Asset_Groups subform correctly shows all related assets for the active asset in the parent form.

    When viewing assets in the Asset_Groups subform, I want to be able to select one and have it become the active record in the parent form. So I set up a Double Click Event for the BarCode field in the subform to perform that task. But I guess I don't know how it should be coded, as it doesn't work right. It just takes me to the first record in the table.

    Code:
    Private Sub BarCode_DblClick(Cancel As Integer)
      Dim Rec_ID As Integer
      Rec_ID = Me.[ID]
      DoCmd.OpenForm "Assets"
      DoCmd.GoToRecord acDataForm, "Assets", acGoTo, Rec_ID
      Me.Parent.Requery
    End Sub
    First of all, I don't know why it complains if I do not explicitly open the parent form, as it is already open.
    I figure I must be headed down the wrong coding path. See screen print of the forms, which shows the Group field in the Parent form and in the child form and the BarCode field in the child form, for which the Double Click Event Procedure is coded.

    Please ignore the second image. I don't know how it got there and I cannot figure out how to get rid of it. Sorry.

    Click image for larger version. 

Name:	Asset Groups.JPG 
Views:	15 
Size:	154.9 KB 
ID:	34791
    Attached Thumbnails Attached Thumbnails Event related forms.JPG  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You are trying to set Offset argument with record ID. Sorry, that's not how the Offset works. Offset is how many records from the first record, not matching value in field.

    Actually, the second image is quite informative. Confirms you are using a Navigation form which I don't like and don't use.

    Try this:
    Code:
    With Forms!ManageSCATeam.NavigationSubform.Form
        .RecordsetClone.FindFirst "ID=" & Me.ID
        .Bookmark = .RecordsetClone.Bookmark
    End With
    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
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    That works great! Thank you. I don't understand what is going on with it, but it does what I need it to do. Access has such a steep learning curve. In the DOS days, I used to program in Clipper. While one had to do more of the busy work in Clipper, at least there was far less to learn.

    I researched this leading dot and Bookmark syntax online, and learned that the leading dot operator is refers to the With object and the Bookmark is associated with the ID of a record in the form, though not the same as the ID.

    I realize using Group this way is not normalized, but it hardly seemed worth creating a grouping table just for this purpose.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-04-2017, 01:16 AM
  2. Replies: 4
    Last Post: 02-05-2016, 02:32 PM
  3. Replies: 3
    Last Post: 07-03-2013, 01:20 PM
  4. Replies: 4
    Last Post: 05-17-2011, 06:56 AM
  5. Replies: 1
    Last Post: 12-22-2010, 01:28 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