Page 3 of 3 FirstFirst 123
Results 31 to 34 of 34
  1. #31
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Quote Originally Posted by bubai View Post
    What is an IMO? Do you mean on load event?

    I forgot the name of the term ie Label. My understanding is, labels can be directed to by meeting some criteria or on errors. But in case of the procedure in question, all of the code should be part of the label.
    Code:
    yctr = False  'OMIT THIS LINE IS SUPERFLUOUS
    Exit_BeforeUpdate: yctr = False
     Exit Sub
    Err_BeforeUpdate:
     MsgBox Err.Number & " " & Err.Description
     Resume Exit_BeforeUpdate
    End Sub
    And since these labels here are directed to only on error, (because there is no conditional criteria to goto a label), how come the resume key word will be executed/(Above code which falls under labels I suppose) if there were no error?
    Answering the first part on behalf of Micron.
    IMO = in my opinion

    Looks like I need to explain how code flows in a procedure ...
    Code is followed line by line in turn unless some event tells it to jump somewhere else.
    So as already explained, when no error occurs it reaches Exit_BeforeUpdate, sets yptr false then exits the sub. It does NOT enter the Err_BeforeUpdate section.

    If an error occurs, at that point it jumps to the Err_BeforeUpdate section (omitting anything in between), displays a message then moves back to the Exit_BeforeUpdate section and proceeds as in the previous sentence. Hope that is clear now
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  2. #32
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    IMO in my opinion. IMHO in my honest opinion. AFAIK as far as I know... etc.
    how come the resume key word will be executed/(Above code which falls under labels I suppose) if there were no error?
    Because that's the way it is coded (or so it appears to me). If there is no Exit Sub/Exit Function line before the error handler, there is nothing to stop the error handling block from executing. The code flow is from Sub to End Sub unless something causes it to exit before, or it fails and stops because of an error.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #33
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by isladogs View Post
    Answering the first part on behalf of Micron.
    IMO = in my opinion

    Looks like I need to explain how code flows in a procedure ...
    Code is followed line by line in turn unless some event tells it to jump somewhere else.
    So as already explained, when no error occurs it reaches Exit_BeforeUpdate, sets yptr false then exits the sub. It does NOT enter the Err_BeforeUpdate section.

    If an error occurs, at that point it jumps to the Err_BeforeUpdate section (omitting anything in between), displays a message then moves back to the Exit_BeforeUpdate section and proceeds as in the previous sentence. Hope that is clear now
    Thanks mate!
    Very much clear now.

  4. #34
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Quote Originally Posted by Micron View Post
    Because that's the way it is coded (or so it appears to me). If there is no Exit Sub/Exit Function line before the error handler, there is nothing to stop the error handling block from executing. The code flow is from Sub to End Sub unless something causes it to exit before, or it fails and stops because of an error.
    Cheers mate!
    I thought Labels were not executed on their own. But it's clear now.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Variable Declaration in MS Access 2013 VBA
    By msaccessdev in forum Programming
    Replies: 7
    Last Post: 06-09-2014, 11:09 AM
  2. Getting Variable from Module to Report
    By dylcon in forum Modules
    Replies: 3
    Last Post: 02-14-2014, 03:43 PM
  3. Create new form instance at the module level
    By DevSteve in forum Modules
    Replies: 1
    Last Post: 09-11-2012, 11:47 AM
  4. Replies: 4
    Last Post: 05-16-2011, 04:58 PM
  5. Variable Table Names in a Module
    By Jessica in forum Modules
    Replies: 1
    Last Post: 04-19-2010, 07:38 PM

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