Results 1 to 9 of 9

Thread: To much Code???

  1. #1
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Unanswered: To much Code???

    Is there such a thing as too much code behind a form?
    I have a form that has conciderable amount of code behind it and today after I added abit more the form suddenly started to take for ever to load. Is it because of the code behind it? if it is any sugestions on what I should do?
    Jim

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    Yes too much code becomes increasingly difficult to find errors, or problems like the form loading issue.

    To help find your delay in loading place a breakpoint on the veryfirst event in your form and walk through the code. You will find that it is loading with stuff you don't need right now. Rearrange the calls and so on so that only the bear minimum is loaded as you need it.

  3. #3
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by dynamictiger
    Yes too much code becomes increasingly difficult to find errors, or problems like the form loading issue.

    To help find your delay in loading place a breakpoint on the veryfirst event in your form and walk through the code. You will find that it is loading with stuff you don't need right now. Rearrange the calls and so on so that only the bear minimum is loaded as you need it.
    Unfortunatly I have neaver used breakpoints, i understand how to set it but what do I do with it after that?
    Jim

  4. #4
    Join Date
    Feb 2002
    Posts
    403
    Place a breakpoint on the line. When the code stops press F8 to step through your code one line at a time.

  5. #5
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Cool that worked great but there is no code that I can illiminate. The form is just slow responding in general when it opens and closes. Does access put all of the code behind a form into memorie when it loads or just what it needs at the time? if it does do you think that I have put so much code into the back ground that it fills that virtual mem up? Is there anything I can do about memorie managment?
    Jim

  6. #6
    Join Date
    Feb 2002
    Posts
    403
    Short answer yes.

    One way around this is to place your large code into modules. In this way Access only loads a module when called. For example:

    If A * B = 6 then
    Do Something
    End if

    Could be placed in a module and then called something like:

    Call DoSomething(A,B)

    Or

    if A * B = 6

    Call DoSomething

    End if

  7. #7
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i'll let a friend of mine deal with this
    VB is cr*p you have to spend half your time waiting
    for the automacte compiler to compile your code and
    tells you that it is wrong even though you are already
    aware of this.
    the problem seem to be that the complier doesn't compile it interprets and interpreting is great for finding errors but it the worst possible method for having fast code
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  8. #8
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by dynamictiger
    Short answer yes.

    One way around this is to place your large code into modules. In this way Access only loads a module when called. For example:

    If A * B = 6 then
    Do Something
    End if

    Could be placed in a module and then called something like:

    Call DoSomething(A,B)

    Or

    if A * B = 6

    Call DoSomething


    End if
    So you are saying that I can put all of my form load code in a modual and in the form load section of my form I can just say call form_load_mod?
    Jim

  9. #9
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    yes, and that should make the code quicker to load, and slower to run as it has to load the module to run the code
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •