Results 1 to 7 of 7
  1. #1
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33

    Multiple Sub Calls not working

    Is there a common reason why a Call from one sub to another sub within the same module would not work.
    For some reason I'm not seeing the Call to RunCode3 never runs.

    Code:
    Private Sub RunCode1()
      Do Something Code
    MsgBox "Do Something Code1 Completed"
          Call RunCode2
    End Sub
    
    Private Sub RunCode2()
       Do Something Code2
    MsgBox "Do Something Code2 Completed"
          Call RunCode3
    End Sub
    
    Private Sub RunCode3()
      Do Something Code3
    MsgBox "All Do Something Code has Completed"
    End Sub
    Also I have tried making all sub's Public

    Thank you in advance for any and all suggestions
    OldCityCat

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    probably have to see the actual code to tell you, there's probably an error in your logic in the runcode2 that is not meeting the conditions to have runcode3 execute.

  3. #3
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    Thanks for you prompt response
    Here's the code in question

    Code:
    'RunCode2
    PrivateSub UpdateAsiaMasterBol()
    OnErrorGoTo ErrorHandler
       DoCmd.SetWarningsFalse
       
    If WhatSeason = "Season 2012"Then
       DoCmd.DeleteObject acTable, "AsiaMasterBol_2012"
       Pause3000
       DoCmd.OpenQuery"qryMakeAsiaMasterBol_2012"
       Pause1000
       DoCmd.OpenQuery"udqryAsiaBolShipperCleanup_2012"
       Pause1000
       MsgBox"Asia Master Bol 2012 Update Completed"
    
    ElseIf WhatSeason = "Season 2013"Then
       DoCmd.DeleteObject acTable, "AsiaMasterBol_2013"
       Pause3000
       DoCmd.OpenQuery"qryMakeAsiaMasterBol_2013"
       Pause1000
       DoCmd.OpenQuery"udqryAsiaBolShipperCleanup_2013"
       Pause1000
       MsgBox"Asia Master Bol 2013 Update Completed"
    
    ElseIf WhatSeason = "Season 2014"Then
       DoCmd.DeleteObject acTable, "AsiaMasterBol_2014"
       Pause3000
       DoCmd.OpenQuery"qryMakeAsiaMasterBol_2014"
       Pause1000
       DoCmd.OpenQuery"udqryAsiaBolShipperCleanup_2014"
       Pause1000
       MsgBox"Asia Master Bol 2014 Update Completed"
    EndIf
    
    ErrorHandler:
      If Err.Number = 3075Then
        Resume ExitProcedure
      EndIf
    ExitProcedure:
         ExitSub
    DoCmd.SetWarningsTrue
    
        MsgBox"Updates Completed", vbSystemModal
    
    'Nothing happend after I Ok this MsgBox
    
    Call UpdateEuropeMasterBol
    EndSub
    ----------------------------------------------------------------
    'RunCode3()
    PrivateSub UpdateEuropeMasterBol()
    OnErrorGoTo ErrorHandler
       DoCmd.SetWarningsFalse
    
    'I never see this MsgBox 
        
    MsgBox"EuropeMasterBOL Started", vbSystemModal
        
    If WhatSeason = "Season 2012"Then
        DoCmd.DeleteObject acTable, "EuropeMasterBol_2012"
        Pause2000
        DoCmd.OpenQuery"qryMakeEuropeMasterBol_2012"
        Pause1000
        DoCmd.OpenQuery"udqryEuropeBolShipperCleanup_2012"
        Pause1000
        MsgBox"Europe Master Bol 2012 Update Completed"
    
    ElseIf WhatSeason = "Season 2013"Then
        DoCmd.DeleteObject acTable, "EuropeMasterBol_2013"
        Pause2000
        DoCmd.OpenQuery"qryMakeEuropeMasterBol_2013"
        Pause1000
        DoCmd.OpenQuery"udqryEuropeBolShipperCleanup_2013"
        Pause1000
        MsgBox"Europe Master Bol 2013 Update Completed"
    
    ElseIf WhatSeason = "Season 2014"Then
        DoCmd.DeleteObject acTable, "EuropeMasterBol_2014"
        Pause2000
        DoCmd.OpenQuery"qryMakeEuropeMasterBol_2014"
        Pause1000
        DoCmd.OpenQuery"udqryEuropeBolShipperCleanup_2014"
        Pause1000
        MsgBox"Europe Master Bol 2014 Update Completed"
    EndIf
    
    ErrorHandler:
    If Err.Number = 3075Then
         Resume ExitProcedure
    EndIf
    ExitProcedure:
      ExitSub
    
    DoCmd.SetWarningsTrue
    MsgBox"Updates Completed", vbSystemModal
    Call UpdateAsiaMasterWithContainers
    EndSub
    

  4. #4
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Comment out "DoCmd.SetWarnings False" and I'll bet you discover one of your queries isn't working.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    I can almost guarantee you that what you're doing is way more complex than it needs to be. I bet all these queries are doing the exact same thing, you have just built a query/procedure for each year.

    That's totally unnecessary.

    However, in the context of your current code you are using EXIT SUB before you ever get to the second procedure call, that's why you never get there


    Code:
    ErrorHandler:
        If Err.Number = 3075 Then
            Resume ExitProcedure
        End If
    ExitProcedure:
        Exit Sub
        DoCmd.SetWarnings True
        MsgBox "Updates Completed", vbSystemModal
        'Nothing happend after I Ok this MsgBox
        Call UpdateEuropeMasterBol
    This is your current code

    Try this instead:

    Code:
    ErrorHandler:
        If Err.Number = 3075 Then
            DoCmd.SetWarnings True
            MsgBox "Updates Completed", vbSystemModal
            'Nothing happend after I Ok this MsgBox
            Call UpdateEuropeMasterBol
            Exit Sub
        End If

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    In other words you are only running the function UPDATEEUROPEMASTERBOL if you get error 3075 on the current function (UpdateAsiaMasterBol)

  7. #7
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    Thanks for see the error of my ways.
    I guess my the error trap was never working
    Fix error trap logic and all Calls are working.

    Thanks

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

Similar Threads

  1. SQL SERVER ADO Calls.
    By majero in forum SQL Server
    Replies: 3
    Last Post: 05-28-2015, 12:07 PM
  2. Tracking calls
    By stange154 in forum Database Design
    Replies: 1
    Last Post: 02-20-2014, 09:49 AM
  3. Creating Form that Calls on Query
    By dbalilti in forum Access
    Replies: 1
    Last Post: 06-21-2012, 09:27 PM
  4. Help with Form & Report that calls a Query
    By bobfin in forum Reports
    Replies: 7
    Last Post: 08-14-2010, 12:05 PM
  5. function calls in a report?
    By kvon in forum Reports
    Replies: 11
    Last Post: 04-25-2010, 08:51 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