Results 1 to 6 of 6
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Saving VBA code

    This may sound like a routine question is MS CCESS 2010. Here it is:



    What is the best way to save code in MS Access 2010 VBA?

    The answer I can see is two different ways: one iffy and one quaranteed.

    The iffy one is after making the VBA code modifications to click away the form
    and when it asks to save, then click yes.

    This works most of the time. Sometimes it does not and that is where the problems
    begin. Sometimes, I think that I have made a changes and saved it this way and then
    I find out latter that it was actually saved. Why, I do not know.

    The second is to make a special effort using the icon in the ribbon. That way when you are done
    you are certain to have saved it. No frustrating efforts to debug code that has already been debugged
    , but it just was not saved.

    I think the later is the best way. Any thoughts.

    Respectfully,

    Lou Reed

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    for modules, in VBE,
    right click module, export File.

    for forms,
    enter vb for the form,
    menu, file, export
    save

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    ranman, I don't think Lou wants to save code as text file, but make sure the VBA edits are committed within the db.

    When closing the db it should ask if you want to save edits if those VBA edits were in general code modules and not previously saved.

    If edits were in object code modules then should be asked to save when closing those objects.

    Otherwise, save manually and frequently especially when doing substantial edits.
    Last edited by June7; 08-15-2017 at 08:37 PM.
    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.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    To me, it is a moot question. Allow me to relate a little story that I was told and came to live by to explain why I say that.

    God wanted to see who was the better programmer; Jesus or the Devil, so God arranged a coding competition. He allotted 3 hours for this competition and provided the best in equipment with all the manuals.

    God and the Devil pounded and clicked furiously for 2 hours and 55 minutes without a break. Just then, the power went out in Heaven. The Devil was astounded, and before he could speak, the power came back on. Jesus continued typing and clicking for 5 more minutes while the Devil scrambled to recover his lost work. When the timer buzzed, God went over to Jesus' desk and took note, then went to the Devil's desk. Of course he had nothing to show for all his time, so God announced Jesus as the winner. The Devil ranted and screamed
    "You are picking Him because He's your son! How could He have possibly recovered all his lost work in 5 minutes!"


    To which God replied,


    "Because Jesus saves."

    Now you will remember to save often and not rely on system prompts to catch your sinful ways.

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I like the idea of just clicking the disk icon on the window ribbon when code is displayed. It then gives a reassuring message that the files has been saved. By clicking the file away and answering yes when the software asks if you want to save the file may work sometimes or it may not. I have had some bad experiences doing that. It works on other applications (like MS Word), but not always in MS Access.

    You think something is saved only to find out later that it was not. you cannot believe how frustrating that is. You go through all the steps to save a file after debugging it and bam! it was not actually saved; debug it again.

    Thanks for your help.

    Respectfully,

    Lou Reed

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You go through all the steps to save a file after debugging it and bam! it was not actually saved;
    If you're on an active object and key Ctrl+S or click the save icon and changes are not saved, or
    you're in the vbe and click toolbar button to save and code is not saved, then you must have a network problem. If you're making changes and closing the object or vbe and hoping changes are being saved, then I agree, it's not good practice. I used to do that - got burned once and said, 'never again'.

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

Similar Threads

  1. Replies: 0
    Last Post: 05-09-2017, 11:04 AM
  2. Replies: 1
    Last Post: 03-17-2017, 08:32 AM
  3. Replies: 3
    Last Post: 04-22-2015, 04:35 AM
  4. Replies: 3
    Last Post: 10-02-2014, 12:03 PM
  5. Saving Module Code to Text Files
    By ioMatt in forum Modules
    Replies: 2
    Last Post: 07-02-2011, 08:18 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