Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-17-2018, 09:53 AM   #1
LukeSky
Newly Registered User
 
Join Date: Aug 2016
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
LukeSky is on a distinguished road
Event associated with combobox don't trigger

Hi, all.

I have two forms, one mainform and another form, form2, that is open from mainform.

In mainform, has one combobox and after inserting data, it trigger event executing macro "test" for showing a msgbox.

In form2, has another combobox that after inserting data, it trigger event executing vba code for changing data mainform's combobox. When close form2 for coming back to mainform, the macro is not triggered in event AfterUpdate.

My question is how I could do for forcing execute that event.

Is necessary that in vba code inserting?:

Code:
docmd.runMacro "test.msg"
If I was using vba for controling that combobox, I know that could use "cbo_AfterUpdate" but it is not my doubt. I would just like to know if there would be another way to force the execution of event AfterUpdate that has one "macro" instead of "Event Procedure".

I attach example database. Thanks in advance and forgive me my english that is not my native language.
Attached Files
File Type: mdb CCO.mdb (1.04 MB, 7 views)


Last edited by LukeSky; 04-17-2018 at 12:53 PM. Reason: [SOLVED]
LukeSky is offline   Reply With Quote
Old 04-17-2018, 11:16 AM   #2
LukeSky
Newly Registered User
 
Join Date: Aug 2016
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
LukeSky is on a distinguished road
Re: Event associated with combobox don't trigger

Ok, I found like do it.

I attach database with solution, hope that be useful for someone.

Thanks. Regards.
Attached Files
File Type: mdb CCO_Solution.mdb (244.0 KB, 11 views)

Last edited by LukeSky; 04-17-2018 at 11:24 AM.
LukeSky is offline   Reply With Quote
Old 04-25-2018, 08:32 AM   #3
tmguru
Newly Registered User
 
Join Date: Apr 2018
Posts: 19
Thanks: 8
Thanked 0 Times in 0 Posts
tmguru is on a distinguished road
Re: Event associated with combobox don't trigger

Hi LukeSky,

Can you please just post the description of the method you used instead of having to open your database.

Thanks!

tmguru is offline   Reply With Quote
Old 04-26-2018, 11:13 AM   #4
LukeSky
Newly Registered User
 
Join Date: Aug 2016
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
LukeSky is on a distinguished road
Re: Event associated with combobox don't trigger

Quote:
Originally Posted by tmguru View Post
Hi LukeSky,

Can you please just post the description of the method you used instead of having to open your database.

Thanks!
Yes, no problem.

The MAINFORM form, has combobox named 'cboData' that has linked to event AfterUpdate
macro 'test.msg'. And command button that open form named 'Form2'

Inside this macro, there are two submacros 'msg' and 'open'. Submacro 'msg' show msgbox with test message, and 'open' open form named 'Form2'.

When 'Form2' is open/loaded, can see other combobox named 'cboInput', and command button 'Exit' that coming back to mainform.

Code of Form2:

Code:
Private Sub cboInput_AfterUpdate()
    MsgBox "Me.cboInput: " & Me.cboInput
    MsgBox "Forms!mainform.cboData: " & Forms!mainform.cboData

End Sub

Private Sub Comando5_Click()
On Error GoTo Err_Comando5_Click

    DoCmd.Close


Exit_Comando5_Click:
    Exit Sub

Err_Comando5_Click:
    MsgBox Err.Description
    Resume Exit_Comando5_Click
    
End Sub


Private Sub Form_Close()
    'MsgBox Me.cboInput
    Me.Visible = False
    If CurrentProject.AllForms("MAINFORM").IsLoaded Then
        Forms!mainform.cboData.SetFocus
        
        If Not IsNull(Me.cboInput) Then
            Forms!mainform.cboData.Text = Me.cboInput
        End If
    End If

End Sub
If you change value of combobox 'cboInput' of 'Form2', when coming back to 'mainform' its combobox 'cboData' will be updated with value selected in combobox 'cboInput' . At the moment, event AfterUpdate of combobox 'cboData' is executing shows msgbox.
LukeSky is offline   Reply With Quote
Old 04-26-2018, 11:41 AM   #5
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 6,348
Thanks: 54
Thanked 2,029 Times in 1,942 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Event associated with combobox don't trigger

On the Close event of the form the value of all controls are destroyed. Use the unload event instead where all the vakues are still intact.

__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Which event Should I use as a trigger? brharrii General 3 04-18-2014 09:40 AM
Event trigger GaelicFatboy Forms 2 12-01-2011 12:54 AM
Trigger Subform Event tuna Forms 3 05-09-2010 04:33 PM
Non-Event to trigger a wav file BarryMK Modules & VBA 11 03-17-2008 05:50 AM
Trigger event when text box value changes lorveney Forms 7 11-20-2007 09:30 AM




All times are GMT -8. The time now is 04:56 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World