Results 1 to 12 of 12
  1. #1
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    How to "cause" a click Event on a Navigator btn on a Navigator control using VBA


    I have created a form with an MSAccess 2010 Navigator control with 4 Navigator Buttons. When the form opens I only enable the first btn and depending on the input open one of the remaining 3 btns. How can you cause a navigator btn click event to occur programmatically in VBA or can you?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Navigation control is just another way to build a Navigation form and I've never used either. Since the 'button' does not show any events in the Properties sheet, I would say no code is possible.
    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
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124
    Dear June thanks for the prompt reply. I have created a form in MSAccess 2010 with a Navigation Control which consists of a Navigation button (NB) (of which I have 4 separate btns in the Navigation Control (NC) and a Navigation Subform. The NB's all have events, and if you click on NB(0) (in my form the first button going from right to left) it opens the form using the form name in the Property:Navigation target Name. I am also trying the Tab control so how can I "Click" the tab using VBA?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I tested creating a Navigation control on form and did not see any events and now think understand why - I did not customize the control and I am not sure how to. I edited my post to remove reference to Tab control but you might have already seen it. I remember now that the events listed for pages of the Tab control don't really work either and I can't remember how to code for the pages, I've never had to. This has been discussed in thread before but can't find it. Think it had something to do with using the Click event of the Tab control, not the pages (tabs).
    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.

  5. #5
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    How to cause a Click event on a control in a form using VBA

    Once again thanks for the prompt reply. My real problem is I don't have a clue as to how to "press" a button. or any other Control with a Click event using VBA. How do you programmatically cause a Click event to happen without physically pressing the control. i.e. Something happens and I magically induce VBA to cause a Click event on a control? I hope that is clear or at least clearer than mud. Thanks

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Still dirty water.

    Select [Event Procedure] in the event property and click the ellipsis to open VBA editor, type code.

    Use mouse to click the button and the code executes.

    Can also use '&' character to set a shortcut key in the button caption or its associated label. This allows typing Alt+character to invoke the button Click event. And if there are no data controls on the form to get focus, don't even need the Alt.

    Also, any event VBA procedure can be called be another procedure.

    So yes, something must happen (an event) to cause code to run.
    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
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    Smile How to cause an Event to occur without having to press the control

    Quote Originally Posted by June7 View Post
    Still dirty water.

    Select [Event Procedure] in the event property and click the ellipsis to open VBA editor, type code.

    Use mouse to click the button and the code executes.

    Can also use '&' character to set a shortcut key in the button caption or its associated label. This allows typing Alt+character to invoke the button Click event. And if there are no data controls on the form to get focus, don't even need the Alt.

    Also, any event VBA procedure can be called be another procedure.

    So yes, something must happen (an event) to cause code to run.
    Thanks June but it is obviously my fault as I am not making the water any clearer. I know how to write code in any event and I have done so BUT I want to execute the code in an Event without physically pressing the button etc. Is this possible? In other words can I say "Run the Click event on buttonOK without physically pressing the button? I think I must have slept through this lecture ;-)

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, an event procedure can be called by another procedure but what event do you want to initiate? SOMETHING must happen or Access will just sit there forever waiting to be told to do something.
    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
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    How to Use VBA to cause navigationControl.NavigationButton to do its thing!

    Quote Originally Posted by June7 View Post
    Yes, an event procedure can be called by another procedure but what event do you want to initiate? SOMETHING must happen or Access will just sit there forever waiting to be told to do something.
    OK thanks June, let me try to explain what I really want to do. In the NaviagationButton control there are navigation buttons which when pressed open a form. The Form opened is in the Properties of the control in the Data section called "Navigation Target name". What I want to do is when I press the navigation btn1 and btn1 displays Form1, I can get the results from an option group and using this choice to decide which 1 of the 3 remaining buttons on the NavigationButton control to enable or make visible and somehow programmatically "Press" that particular btn and have it open a new form based on its "Navigation target Name". IS this possible?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Best answer I have is "Maybe." I've never used Navigation form or Navigation control (really the same thing).

    Instead of trying to execute button Click event, maybe address the "Navigation Target Name" property, something like:

    DoCmd.OpenForm Me.NB(1).NavigationTargetName
    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.

  11. #11
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    Navigator Control in MSAccess 2010

    Quote Originally Posted by June7 View Post
    Best answer I have is "Maybe." I've never used Navigation form or Navigation control (really the same thing).

    Instead of trying to execute button Click event, maybe address the "Navigation Target Name" property, something like:

    DoCmd.OpenForm Me.NB(1).NavigationTargetName
    Once again thanks June for all your hard work . I think Access does some behind the scenes activity so that a NavigationBtnControl opens a form named in the NavigationtargetName property of the navigationBtnControl. I have tried not inputting any form names in the NavigationtargetName property and later tried to set a NavigationtargetName property with a form name in VBA code but no luck. Apparently there is no way to do this on the fly once the NavigationBtnControl is out of Design mode. There is a control named navigationSubForm but I don't know what is does. I'll have to do some more thinking on this once again thanks.

  12. #12
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124
    Quote Originally Posted by JrMontgom View Post
    Once again thanks June for all your hard work . I think Access does some behind the scenes activity so that a NavigationBtnControl opens a form named in the NavigationtargetName property of the navigationBtnControl. I have tried not inputting any form names in the NavigationtargetName property and later tried to set a NavigationtargetName property with a form name in VBA code but no luck. Apparently there is no way to do this on the fly once the NavigationBtnControl is out of Design mode. There is a control named navigationSubForm but I don't know what is does. I'll have to do some more thinking on this once again thanks.
    June, I guess serendipity is alive and well. I stumbled on an article that talked about the method Browseto and demonstrated how to use the method.
    In my case I have a NavigationControl (NC) and 4 NavigationBtn's (NB). On the first form that opens from the NC I have an option group and 2 cmd buttons. On the OK btn I make a decision which form to go to and then I use the following in the OK btn Click event:

    DoCmd.BrowseTo acBrowseToForm, "frmDLGGetDates2", , , , acFormEdit

    This puts the frmDLGGetDates2 into the navigationSubForm and shows it i.e. the same as pressing the 2nd btn on the NB control. I also use another fucntion todo some housecleaning setting the NB.enabled property to True or False which shows the non-active NB's as"faded".

    Here is the reference for the navigation control in MSAccess 2010. ;-)
    http://blogs.office.com/2010/02/23/a...-macro-action/

    Pay it forward, thanks June
    Last edited by June7; 04-01-2014 at 03:35 PM.

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

Similar Threads

  1. saves data with out click "Save" button in forms
    By terrythomasvda in forum Forms
    Replies: 4
    Last Post: 01-14-2013, 01:31 PM
  2. Using "On Click" or "On Dbl Click" in a Switchboard
    By James Parker in forum Access
    Replies: 2
    Last Post: 01-12-2012, 11:00 AM
  3. Replies: 1
    Last Post: 10-15-2011, 01:12 PM
  4. Navigator Pane issue
    By thedoc44 in forum Access
    Replies: 1
    Last Post: 09-17-2010, 04:52 PM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

Tags for this Thread

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