Results 1 to 5 of 5
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    Subroutine VBA - Jump


    So is it possible to have a subroutine where the code gets to a certain point/condition whereby you could jump back to a specific point in the subroutine? Or perhaps jump from one subroutine to another and back again?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Sure, both are possible. More info about what you're trying to achieve will probably yield the best response. You can use GoTo to send code to a specific spot, though it's considered bad practice to use it much (spaghetti code). If you call a sub/function code will go perform that process then return.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    what would be the syntax for calling another subroutine in the same module?

    module is [Form_FrmFTLoop]
    Private Sub BtnSearch_Click() calls Private Sub Form_AfterUpdate()

  4. #4
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    I figured it out....

    within Private Sub BtnSearch_Click() write:

    Form_AfterUpdate

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it working. Personally if something needs to be called from multiple places I'll create a sub/function and call it from those places.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Jump To Record
    By ortizimo in forum Access
    Replies: 5
    Last Post: 09-13-2019, 08:57 AM
  2. Jump to Record
    By control1 in forum Access
    Replies: 16
    Last Post: 04-07-2017, 10:18 AM
  3. Query not running right in subroutine
    By Historypaul in forum Programming
    Replies: 8
    Last Post: 01-29-2013, 06:42 AM
  4. Calling Access VBA subroutine from an Excel VBA subroutine
    By richard_yolland in forum Programming
    Replies: 0
    Last Post: 02-16-2011, 11:30 AM
  5. Referencing a Subroutine
    By Lockrin in forum Programming
    Replies: 1
    Last Post: 02-26-2010, 10:09 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