Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by accesstos View Post
    It must appear the [Event Procedure] in the On Current event of the form in the Property Sheet to run the event(!).
    It's one of quirks of Access.
    I'm not clear what you mean. That was present and the code was running, it was throwing an error. It sounds like the master/child links may have been the problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    I'm not clear what you mean.
    I mean this:

    Click image for larger version. 

Name:	OnCurrent.JPG 
Views:	11 
Size:	16.4 KB 
ID:	36806

    If the"[Event Procedure]"is missing, the "Form_Current()" event not occur, even if it's code is already in the class module.

    BTW, I think that this issue, using the OnCurrent event of the forms, drives to infinity loop and bookmark problems.
    If the goal is to display addition details in main form of the selected asset through the subform,
    i recommend the usage of one more subform with the particular fields (images, descriptions etc),
    controled by the subform "Asset Groups" with user-defined events between the subforms.

    Underneath, you can see the code of two subforms.
    The subform "Form1" fires the event when the OnCurrent event occurs and the other form(s)
    going to the particular record using the value passed from this event.

    Code:
    Option Compare Database
    Option Explicit
    
    'Form1's class module (Ex. "Asset Groups subform". The "navigation" form)
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'Public Event declaration
    Public Event AssetChange(varID As Variant)
    '
    
    Private Sub Form_Current()
        RaiseEvent AssetChange(Me.My_ID)
    End Sub
    Code:
    Option Compare Database
    Option Explicit
    
    'Class module of any form that wants catch the Form1's event(s)
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Private WithEvents sForm1 As Form_Form1 'Keeps an instance of the Form1
    '
    
    Private Sub Form_Load()
        Set sForm1 = Me.Parent.Form1.Form
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Set sForm1 = Nothing
    End Sub
    
    Private Sub sForm1_AssetChange(varID As Variant)
        Me.Recordset.FindFirst "[My_ID]=" & varID
    End Sub
    That solves the problems of master/child links and the "Asset Group" subform can keep then link with the Main form as it was.

  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You don't seem to be getting that the code was running, it was throwing an error as it ran.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Quote Originally Posted by pbaldy View Post
    You don't seem to be getting that the code was running, it was throwing an error as it ran.
    I don't know where did you try it and I can't open SCATeam database in my system to test it, so, I attach a sample database who demonstrates the functionality of custom events on communication between forms.
    Two popup single forms (frmPopQuote1 and frmPopQuote2) are listening the custom events of a third datasheet form (frmQuotes), and the second popup form controls the datasheet form directly by the private object variable.

    Hope enjoy it!
    Attached Files Attached Files

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 02-11-2018, 02:06 PM
  2. Replies: 1
    Last Post: 12-30-2013, 05:56 PM
  3. Update Main Form From Subform
    By burrina in forum Forms
    Replies: 7
    Last Post: 02-06-2013, 03:55 PM
  4. Requery subform after update of main form
    By gemadan96 in forum Forms
    Replies: 3
    Last Post: 10-17-2012, 02:33 PM
  5. Navigating from Form to SubForm
    By Gryphen957 in forum Forms
    Replies: 1
    Last Post: 11-19-2010, 10:08 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