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

    Synchronize a main form from it subform

    I have a Main form (Navigation Sub-form) with two sub-forms
    Code:
    Assets
         Asset Tracking
         Asset Groups
    As I move from one record to the next in the Asset Groups sub-form, I want the Main form to display that Asset Record.
    Currently, I have it programmed so that when I Dbl-Clk on the Tag column in an Asset Groups record, it synchronizes the main form to show that record. This works fine. However, I would rather have it so the main form synchronizes as I move from record to record in the Asset Groups sub-form, either by using the mouse or clicking in the navigation column of a record.

    The On Current event property for the sub-form seems to do just that, so I thought I would just copy the code from the On Double Click event property into the On Current event property. However, it errors out on the ".Bookmark =..." line, when used in the context of the On Current property.



    Below, is the code which works in the Double Click property of the Tag column. How can I modify this to work with the On Current property of the sub-form? The name of the field in the Tag column is "BarCode".
    Code:
    Private Sub BarCode_DblClick(Cancel As Integer)
    With Forms![Manage SCATeam].NavigationSubform.Form
        .RecordsetClone.FindFirst "ID=" & Me.ID
        .Bookmark = .RecordsetClone.Bookmark
    End With
    End Sub
    Screen Print:
    Click image for larger version. 

Name:	Asset Groups.JPG 
Views:	27 
Size:	213.7 KB 
ID:	35923
    Last edited by WCStarks; 10-22-2018 at 04:04 PM.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I never use Navigation forms - they are notoriously difficult to work with.

    Any chance you would post your dB here? Just need a couple of main form records with maybe 10 sub form records....

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Since you requested in a recent thread for review of this one, will make comment.

    The behavior you describe is what a Split form does.

    I also don't like Navigation form.

    If you get an error, what is it?

    I am somewhat confused. Code appears to reference RecordsetClone of subform not main form so I don't know how your code could work at all. The following works for me.

    Code:
    Private Sub Form_Current()
    With Forms![Manage SCATeam]
        .RecordsetClone.FindFirst "ID=" & Me.ID
        .Bookmark = .RecordsetClone.Bookmark
    End With
    End Sub
    
    Private Sub BarCode_DblClick(Cancel As Integer)
    With Forms![Manage SCATeam]
        .RecordsetClone.FindFirst "ID=" & Me.ID
        .Bookmark = .RecordsetClone.Bookmark
    End With
    End Sub
    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.

  4. #4
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Had I it to do over again, I would not have used the Navigation Forms feature. It did what I needed to do, so it seemed the right thing to do at the time. I understand now, that there are other ways to do what it does.

    I have sanitized the database to post. You are only interested in the Navigation Tab for Assets. Find an asset in the GoTo Combo Box in the Assets form, which includes a value in the Group field, such as Mesh. When you select it, other records with that same value will display in the Asset Groups sub-form.

    Double Click on the tag column in a row of the Asset Groups sub-form and see that the Asset in the main form updates to that asset.

    I want to be able to click in the Navigation column on a row, or browse from one to the other row in the Asset Groups sub-form using the arrow keys, etc. and have the record in the Asset Form sync with the current row in the Groups sub-form.

    FYI. There is a large blank square on the right side of the Assets form. That is where a picture of the asset normally displays. The Assets form wraps around the right side of the two sub-forms.

    SCATeam.zip

  5. #5
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Some one in the Forum helped me do this code for the BarCode DblClick property. The Link Master and Link Child fields of the Asset Groups sub-form are set to [Group] to get the Assets Group sub-form to show other assets belonging to that same group. Check the thread above for the sanitized db.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I have never tried to build an emulation of Split form. This is very annoying. I am at a loss as to why the DblClick works but OnCurrent does not. Set a break point in the OnCurrent event (or a Debug.Print "Current" at beginning of procedure) and you will see that the procedure executes 3 times. No error when first clicking the Asset tab (the OnCurrent does run), only when trying to change record. Why does the subform want to always return to top record? If there is code somewhere causing this interference, I can't find.

    Side notes:
    Found code that requeries a checkbox. That makes no sense.
    I always name subform container control different from the object it holds, such as ctrAssetGrp.
    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
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Thanks for your response
    1) I didn't know about a Split form. I will study that to better understand it. Would implementing a real Split form provide the desired syncing as I browse through the Asset Groups sub-form?
    2) I'm not sure which code you are referring to that requires a checkbox. I wonder if it is the Active checkbox, which is located in the top form called "Manage SCATeam". I use that for combo-boxes which select Members to link to, to restrict selection options to only Active members or All members.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, split form will synchronize. There is no form/subform, it is a solo form. I have used only once. You can place a subform for related data into a Split form. Possibly a Split form can be the Navigation Target for a Navigation Button.

    Yes, it is that checkbox. Requerying a checkbox makes no sense to me. Possibly you mean to requery combobox?
    Last edited by June7; 10-23-2018 at 05:34 PM.
    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.

  9. #9
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    When I disabled the checkbox requery, the combo-box no longer senses the change. I tried doing a requery on the combo-box's Before Update and On Click properties, but they did nothing. When I re-enabled the checkbox requery, the combo box sensed the change again. So, I don't know how to make it work without requerying the checkbox. I also don't remember how I came to do that requery in the first place. I also reference that check-box for various reports.

  10. #10
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    I did some checking, and apparently a split form cannot be a sub-form, which suggests it cannot be used in a Navigation Sub-form layout. So, it appears my best option is as I have done to emulate a split form with a sub-form.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Okay, then back to the issue of why subform insists on returning to top row when those events run. This does not interfere when DblClick event runs but apparently it does for OnCurrent. Sorry, I have no solution for this. But others have gotten emulation to work https://access-programmers.co.uk/for...d.php?t=293854

    Perhaps the reason yours fails is you are not linking on key field.

    And now requery of checkbox makes sense. The checkbox value is not updated until it loses focus. This is why I advise put combobox requery in its own GotFocus event.
    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. Replies: 39
    Last Post: 07-28-2018, 12:27 PM
  2. Replies: 6
    Last Post: 02-11-2018, 02:06 PM
  3. Replies: 10
    Last Post: 07-05-2017, 11:31 AM
  4. Replies: 3
    Last Post: 06-29-2017, 03:02 PM
  5. Replies: 4
    Last Post: 11-06-2014, 05:35 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