Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Calling AfterUpdate Event on Separate Form

Discussion in 'Information Technology' started by bhikku, Jul 28, 2006.

  1. bhikku

    bhikku
    Expand Collapse
    Guest

    I want to trigger the AfterUpdate event on a combo box on one form from the
    AfterUpdate event on another form.

    Here is the sequence:
    - FormA opens
    - FormB opens
    - A value is selected from a combo box in FormB
    - The source table for FormA is updated by the combo box in FormB
    - The AfterUpdate event in a combo box in FormA is triggered, which updates
    all of FormA
    - FormB closes

    I have this code in the AfterUpdate event for the combo box in FormB:

    Forms.FormA.SetFocus
    Forms.FormA.cmbSelectList_AfterUpdate
    Forms.FormB.SetFocus
    DoCmd.Close

    The second line generates the error "Application-defined or object-defined
    error".

    How do I call an event on an object in a separate form?

    b
     
  2. Loading...

    Similar Threads Forum Date
    Your Calling Get Involved Jun 5, 2016
    How Harnarayan Singh Found His Calling Sikh Personalities Apr 13, 2016
    Zen & UnZen Moments...Who Are You Calling Yo-Yo...? Inspirational Stories Jul 14, 2013
    SALDEF Calling All College Students and Recent Graduates! (SALDEF) Sikh Organisations Mar 15, 2011
    General What is Your Calling: Expanding the Conversation about Why We Are Here Hard Talk Jan 3, 2011

  3. microb0x

    microb0x
    Expand Collapse
    Guest

    You are not going to be able to call the AfterUpdate event like that.
    It is an event that occurs after an object is updated and is not
    something you can call.

    Why not just include the code you want to run in the AfterUpdate event
    of the combo box in FormB? Or just create a public function that you
    can call in both AfterUpdate events.


    bhikku wrote:
    > I want to trigger the AfterUpdate event on a combo box on one form from the
    > AfterUpdate event on another form.
    >
    > Here is the sequence:
    > - FormA opens
    > - FormB opens
    > - A value is selected from a combo box in FormB
    > - The source table for FormA is updated by the combo box in FormB
    > - The AfterUpdate event in a combo box in FormA is triggered, which updates
    > all of FormA
    > - FormB closes
    >
    > I have this code in the AfterUpdate event for the combo box in FormB:
    >
    > Forms.FormA.SetFocus
    > Forms.FormA.cmbSelectList_AfterUpdate
    > Forms.FormB.SetFocus
    > DoCmd.Close
    >
    > The second line generates the error "Application-defined or object-defined
    > error".
    >
    > How do I call an event on an object in a separate form?
    >
    > b
     
  4. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Sorry, but that's not correct. The code is simply VBA code that gets called
    by an event. You can call the code the same as you can any other VBA.

    Two things.

    Procedures associated with events are always written as Private Sub
    control_event(), such as Private Sub cmbSelectList_AfterUpdate(). In order
    to be able to call the code from outside of the form, you need to change
    that declaraton to Public Sub cmbSelectList_AfterUpdate()

    To call it, you need to use:

    Call Form _FormA.cmbSelectList_AfterUpdate

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "microb0x" <wolffmike@gmail.com> wrote in message
    news:1152647682.078240.274310@75g2000cwc.googlegroups.com...
    > You are not going to be able to call the AfterUpdate event like that.
    > It is an event that occurs after an object is updated and is not
    > something you can call.
    >
    > Why not just include the code you want to run in the AfterUpdate event
    > of the combo box in FormB? Or just create a public function that you
    > can call in both AfterUpdate events.
    >
    >
    > bhikku wrote:
    > > I want to trigger the AfterUpdate event on a combo box on one form from

    the
    > > AfterUpdate event on another form.
    > >
    > > Here is the sequence:
    > > - FormA opens
    > > - FormB opens
    > > - A value is selected from a combo box in FormB
    > > - The source table for FormA is updated by the combo box in FormB
    > > - The AfterUpdate event in a combo box in FormA is triggered, which

    updates
    > > all of FormA
    > > - FormB closes
    > >
    > > I have this code in the AfterUpdate event for the combo box in FormB:
    > >
    > > Forms.FormA.SetFocus
    > > Forms.FormA.cmbSelectList_AfterUpdate
    > > Forms.FormB.SetFocus
    > > DoCmd.Close
    > >
    > > The second line generates the error "Application-defined or

    object-defined
    > > error".
    > >
    > > How do I call an event on an object in a separate form?
    > >
    > > b

    >
     
  5. microb0x

    microb0x
    Expand Collapse
    Guest

    I apologize, I was unaware you could change an event procedure for a
    form to Public.


    Douglas J Steele wrote:
    > Sorry, but that's not correct. The code is simply VBA code that gets called
    > by an event. You can call the code the same as you can any other VBA.
    >
    > Two things.
    >
    > Procedures associated with events are always written as Private Sub
    > control_event(), such as Private Sub cmbSelectList_AfterUpdate(). In order
    > to be able to call the code from outside of the form, you need to change
    > that declaraton to Public Sub cmbSelectList_AfterUpdate()
    >
    > To call it, you need to use:
    >
    > Call Form _FormA.cmbSelectList_AfterUpdate
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "microb0x" <wolffmike@gmail.com> wrote in message
    > news:1152647682.078240.274310@75g2000cwc.googlegroups.com...
    > > You are not going to be able to call the AfterUpdate event like that.
    > > It is an event that occurs after an object is updated and is not
    > > something you can call.
    > >
    > > Why not just include the code you want to run in the AfterUpdate event
    > > of the combo box in FormB? Or just create a public function that you
    > > can call in both AfterUpdate events.
    > >
    > >
    > > bhikku wrote:
    > > > I want to trigger the AfterUpdate event on a combo box on one form from

    > the
    > > > AfterUpdate event on another form.
    > > >
    > > > Here is the sequence:
    > > > - FormA opens
    > > > - FormB opens
    > > > - A value is selected from a combo box in FormB
    > > > - The source table for FormA is updated by the combo box in FormB
    > > > - The AfterUpdate event in a combo box in FormA is triggered, which

    > updates
    > > > all of FormA
    > > > - FormB closes
    > > >
    > > > I have this code in the AfterUpdate event for the combo box in FormB:
    > > >
    > > > Forms.FormA.SetFocus
    > > > Forms.FormA.cmbSelectList_AfterUpdate
    > > > Forms.FormB.SetFocus
    > > > DoCmd.Close
    > > >
    > > > The second line generates the error "Application-defined or

    > object-defined
    > > > error".
    > > >
    > > > How do I call an event on an object in a separate form?
    > > >
    > > > b

    > >
     
  6. bhikku

    bhikku
    Expand Collapse
    Guest

    Bingo! It was the Public/Private declaration. It works fine now.

    Thank you!

    b

    "microb0x" <wolffmike@gmail.com> wrote in message
    news:1152651795.178861.151110@m73g2000cwd.googlegroups.com...
    >I apologize, I was unaware you could change an event procedure for a
    > form to Public.
    >
    >
    > Douglas J Steele wrote:
    >> Sorry, but that's not correct. The code is simply VBA code that gets
    >> called
    >> by an event. You can call the code the same as you can any other VBA.
    >>
    >> Two things.
    >>
    >> Procedures associated with events are always written as Private Sub
    >> control_event(), such as Private Sub cmbSelectList_AfterUpdate(). In
    >> order
    >> to be able to call the code from outside of the form, you need to change
    >> that declaraton to Public Sub cmbSelectList_AfterUpdate()
    >>
    >> To call it, you need to use:
    >>
    >> Call Form _FormA.cmbSelectList_AfterUpdate
    >>
    >> --
    >> Doug Steele, Microsoft Access MVP
    >> http://I.Am/DougSteele
    >> (no e-mails, please!)
    >>
    >>
    >> "microb0x" <wolffmike@gmail.com> wrote in message
    >> news:1152647682.078240.274310@75g2000cwc.googlegroups.com...
    >> > You are not going to be able to call the AfterUpdate event like that.
    >> > It is an event that occurs after an object is updated and is not
    >> > something you can call.
    >> >
    >> > Why not just include the code you want to run in the AfterUpdate event
    >> > of the combo box in FormB? Or just create a public function that you
    >> > can call in both AfterUpdate events.
    >> >
    >> >
    >> > bhikku wrote:
    >> > > I want to trigger the AfterUpdate event on a combo box on one form
    >> > > from

    >> the
    >> > > AfterUpdate event on another form.
    >> > >
    >> > > Here is the sequence:
    >> > > - FormA opens
    >> > > - FormB opens
    >> > > - A value is selected from a combo box in FormB
    >> > > - The source table for FormA is updated by the combo box in FormB
    >> > > - The AfterUpdate event in a combo box in FormA is triggered, which

    >> updates
    >> > > all of FormA
    >> > > - FormB closes
    >> > >
    >> > > I have this code in the AfterUpdate event for the combo box in FormB:
    >> > >
    >> > > Forms.FormA.SetFocus
    >> > > Forms.FormA.cmbSelectList_AfterUpdate
    >> > > Forms.FormB.SetFocus
    >> > > DoCmd.Close
    >> > >
    >> > > The second line generates the error "Application-defined or

    >> object-defined
    >> > > error".
    >> > >
    >> > > How do I call an event on an object in a separate form?
    >> > >
    >> > > b
    >> >

    >
     
  7. Wolfgang Kais

    Wolfgang Kais
    Expand Collapse
    Guest

    Hello "bhikku".

    "bhikku" wrote:
    > I want to trigger the AfterUpdate event on a combo box on one form
    > from the AfterUpdate event on another form.
    >
    > Here is the sequence:
    > - FormA opens
    > - FormB opens
    > - A value is selected from a combo box in FormB
    > - The source table for FormA is updated by the combo box in FormB
    > - The AfterUpdate event in a combo box in FormA is triggered, which
    > updates all of FormA
    > - FormB closes
    >
    > I have this code in the AfterUpdate event for the combo box in FormB:
    >
    > Forms.FormA.SetFocus
    > Forms.FormA.cmbSelectList_AfterUpdate
    > Forms.FormB.SetFocus
    > DoCmd.Close
    >
    > The second line generates the error "Application-defined or
    > object-defined error".
    >
    > How do I call an event on an object in a separate form?


    Try the following:
    Create a public sub DoWhatever in the module of FormA and move
    the code of the cmbSelectList_AfterUpdate procedure there. Call this
    new sub from the cmbSelectList_AfterUpdate procedure. In FormB,
    execute the following code in the AfterUpdate event of the combobox:

    Forms![FormA].DoWhatever
    DoCmd.Close acForm, Me.Name

    --
    Regards,
    Wolfgang
     
  8. Wolfgang Kais

    Wolfgang Kais
    Expand Collapse
    Guest

    Hello "bhikku".

    "bhikku" wrote:
    > I want to trigger the AfterUpdate event on a combo box on one form
    > from the AfterUpdate event on another form.
    >
    > Here is the sequence:
    > - FormA opens
    > - FormB opens
    > - A value is selected from a combo box in FormB
    > - The source table for FormA is updated by the combo box in FormB
    > - The AfterUpdate event in a combo box in FormA is triggered, which
    > updates all of FormA
    > - FormB closes
    >
    > I have this code in the AfterUpdate event for the combo box in FormB:
    >
    > Forms.FormA.SetFocus
    > Forms.FormA.cmbSelectList_AfterUpdate
    > Forms.FormB.SetFocus
    > DoCmd.Close
    >
    > The second line generates the error "Application-defined or
    > object-defined error".
    >
    > How do I call an event on an object in a separate form?


    Try the following:
    Create a public sub DoWhatever in the module of FormA and move
    the code of the cmbSelectList_AfterUpdate procedure there. Call this
    new sub from the cmbSelectList_AfterUpdate procedure. In FormB,
    execute the following code in the AfterUpdate event of the combobox:

    Forms![FormA].DoWhatever
    DoCmd.Close acForm, Me.Name

    --
    Regards,
    Wolfgang
     

Share This Page