Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-19-2017, 10:38 AM   #1
vent
Newly Registered User
 
Join Date: May 2017
Posts: 101
Thanks: 17
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Decompile : general rule of thumb?

Hi everyone

A rookie programmer here, just wanting to get more information. I'm noticing most (if not every time) I add new VBA code, things work fine momentarily but afterwards there seems to be some sort of error that comes along with the addition of new VBA (e.g. form won't open due to programming error, microsoft access stops working, etc). I've been following the decompile method for a while now so I'm just wondering, should I decompile every time I add new VBA code? Then compact & repair? Is this recommended or should I only decompile whenever an error is present? Any feedback is much appreciated!


Last edited by vent; 05-19-2017 at 11:01 AM. Reason: spelling errors and clarification
vent is offline   Reply With Quote
Old 05-19-2017, 11:00 AM   #2
moke123
Newly Registered User
 
Join Date: Jan 2013
Location: Massachusetts
Posts: 402
Thanks: 0
Thanked 130 Times in 123 Posts
moke123 is on a distinguished road
Re: Decompile : general rule of thumb?

do you have Option Explicit declared in every module? does your code Compile without errors? I tend to consider De-compiling as a last resort.
moke123 is offline   Reply With Quote
Old 05-19-2017, 11:02 AM   #3
BigHappyDaddy
Coding Monkey Wanna-Be
 
BigHappyDaddy's Avatar
 
Join Date: Aug 2012
Location: Puyallup, WA
Posts: 170
Thanks: 6
Thanked 36 Times in 35 Posts
BigHappyDaddy is on a distinguished road
Re: Decompile : general rule of thumb?

So in no way am I an authority, but in practice:
I Compact && Repair (during development) generally just to reduce database bloat (caused by multiple append / make tables then delete queries). I make use of temporary "side" databases to handle any temp tables that are usually subject to bloat (at least in my coding style).
I also Compact Repair right before publishing my database to Production.
I don't decompile near as much, but maybe after an error is generated that does not appear either logic / syntax related or data related. But this is quire rare in my experience.
I will decompile a project if it has been under development with numerous and significant changes over a long period of time.
I don't find any significant advantage in decompiling any more than "occasionally" when under development.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BigHappyDaddy is offline   Reply With Quote
Old 05-19-2017, 11:11 AM   #4
vent
Newly Registered User
 
Join Date: May 2017
Posts: 101
Thanks: 17
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: Decompile : general rule of thumb?

Quote:
Originally Posted by moke123 View Post
do you have Option Explicit declared in every module? does your code Compile without errors? I tend to consider De-compiling as a last resort.
I don't have option explicit on every module. Even though everything works fine now, should I still do it?
vent is offline   Reply With Quote
Old 05-19-2017, 12:08 PM   #5
The_Doc_Man
AWF VIP
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 10,655
Thanks: 36
Thanked 834 Times in 748 Posts
The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all
Re: Decompile : general rule of thumb?

You might catch something by adding Option Explicit and it might be useful. You see, in the absence of a Dim x as type statement, if you have a "created-on-the-fly" variable, it is a Variant type, which can be anything, which is OK, and can change types without you knowing it, which is NOT OK.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over six months and survived being home all day with the wife. She must really love me.
The_Doc_Man is offline   Reply With Quote
Old 05-19-2017, 03:53 PM   #6
moke123
Newly Registered User
 
Join Date: Jan 2013
Location: Massachusetts
Posts: 402
Thanks: 0
Thanked 130 Times in 123 Posts
moke123 is on a distinguished road
Re: Decompile : general rule of thumb?

Quote:
I don't have option explicit on every module. Even though everything works fine now, should I still do it?
yes, you should. go to tools>options in the vbe and check "Require Variable Declaration".
moke123 is offline   Reply With Quote
Old 05-19-2017, 06:18 PM   #7
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 9,464
Thanks: 36
Thanked 3,056 Times in 2,971 Posts
CJ_London is a jewel in the rough CJ_London is a jewel in the rough CJ_London is a jewel in the rough
Re: Decompile : general rule of thumb?

I concur with everyone - use Option Explicit

In addition to Mokes post, this will only add Option Explicit to new modules - manually go into existing modules (all of them) and add just below the Option Compare Database line at the top.

During development, after every addition of a few lines of code, click on the Debug menu and select compile to check for errors - it takes a fraction of a second

there are five basic types of errors

syntax errors- advised by the vba editor as you type
naming errors - advised when you compile
logic errors - also advised when you compile
value errors - caught when the app is run
calculation errors - caught when the app is run

if you don't compile, the naming and logic errors are caught when the app is run and might instead appear to be a value or calculation error.

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button

Last edited by CJ_London; 05-19-2017 at 06:20 PM. Reason: deleted wrong advice
CJ_London is offline   Reply With Quote
Old 05-22-2017, 03:53 PM   #8
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 5,975
Thanks: 11
Thanked 628 Times in 592 Posts
missinglinq is just really nice missinglinq is just really nice missinglinq is just really nice missinglinq is just really nice missinglinq is just really nice
Re: Decompile : general rule of thumb?

Also, note that Compact & Repair is considered by many experienced developers to be a major cause of corruption, and hence it's probably a good idea to always make a safe backup copy of your file before running a C & R.

Linq ;0)>
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 05-23-2017, 04:58 AM   #9
vent
Newly Registered User
 
Join Date: May 2017
Posts: 101
Thanks: 17
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: Decompile : general rule of thumb?

Thanks everyone!
vent is offline   Reply With Quote
Old 05-23-2017, 05:16 AM   #10
vent
Newly Registered User
 
Join Date: May 2017
Posts: 101
Thanks: 17
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: Decompile : general rule of thumb?

Ok so before the long weekend I managed to work on creating a classic login form for the database I'm working on, everything worked fine before leaving. This morning upon opening the login form I entered a random user's credentials, pressed enter and I got the same error I encountered previously, which was openform action was cancelled, I opened the debugger and the same line of code was highlighted yellow, I decompiled the database then closed it. When I reopened it, the login form was gone. Luckily I saved a copy of the database and the login form works fine. I went to every module now and typed out Option Explicit and went to tools>options and checked "Require Variable Declaration" and everything is fine and dandy...for now. I'm just wondering should I keep making backup copies every time until the final product is complete? I just don't want these errors coming up for those who will be using this database daily. Thank you!

Last edited by vent; 05-23-2017 at 05:17 AM. Reason: adding more important info
vent is offline   Reply With Quote
Old 05-23-2017, 05:30 AM   #11
The_Doc_Man
AWF VIP
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 10,655
Thanks: 36
Thanked 834 Times in 748 Posts
The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all
Re: Decompile : general rule of thumb?

Quote:
I'm just wondering should I keep making backup copies every time until the final product is complete?
As you stated this rhetorical question, that answer is actually NO. You should keep making backup copies even AFTER the product is complete. Because... no product is EVER complete. It just has more fixes and/or new features than its previous version.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over six months and survived being home all day with the wife. She must really love me.
The_Doc_Man is offline   Reply With Quote
Old 05-23-2017, 07:53 AM   #12
Stormin
Nawly Ragistarad Usar
 
Join Date: Dec 2016
Location: UK
Posts: 50
Thanks: 8
Thanked 6 Times in 4 Posts
Stormin is on a distinguished road
Re: Decompile : general rule of thumb?

I'm no expert either, however I have a db that is in development but also is semi-live (being used but not a finished product). I have the version number in the database name in options > current database. I keep all version history and any changes I make in a changelog, and I backup the database every day. That way if something goes wrong it's easier to track down what it might have been and what version I'm rolling back to.

At the end of the week I backup THEN compact & repair as I have experienced corruption from C&R before. A whole table was deleted with no warnings or errors. Luckily I could go to the back and restore it once I realised it was missing.

I have never needed to decompile this database after ~6 months of development.
Stormin is offline   Reply With Quote
Old 05-23-2017, 09:27 AM   #13
vent
Newly Registered User
 
Join Date: May 2017
Posts: 101
Thanks: 17
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: Decompile : general rule of thumb?

Quote:
Originally Posted by Stormin View Post
I'm no expert either, however I have a db that is in development but also is semi-live (being used but not a finished product). I have the version number in the database name in options > current database. I keep all version history and any changes I make in a changelog, and I backup the database every day. That way if something goes wrong it's easier to track down what it might have been and what version I'm rolling back to.

At the end of the week I backup THEN compact & repair as I have experienced corruption from C&R before. A whole table was deleted with no warnings or errors. Luckily I could go to the back and restore it once I realised it was missing.

I have never needed to decompile this database after ~6 months of development.
How am I able to use a "changelog" and also version numbers under "current database"?
vent is offline   Reply With Quote
Old 05-23-2017, 12:12 PM   #14
The_Doc_Man
AWF VIP
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 10,655
Thanks: 36
Thanked 834 Times in 748 Posts
The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all The_Doc_Man is a name known to all
Re: Decompile : general rule of thumb?

From that location, you don't. You create a table to track version numbers. The one with the most recent change date is the current version of the DB. Or, the only entry that is NOT marked "obsolote" is the current entry (and you manually update that table to assure the correct flag placement/value.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over six months and survived being home all day with the wife. She must really love me.
The_Doc_Man is offline   Reply With Quote
Old 05-24-2017, 12:06 AM   #15
Stormin
Nawly Ragistarad Usar
 
Join Date: Dec 2016
Location: UK
Posts: 50
Thanks: 8
Thanked 6 Times in 4 Posts
Stormin is on a distinguished road
Re: Decompile : general rule of thumb?

I actually use a separate Excel file instead, that way I can preserve my log if I have to roll back or something bad happens to the db. As Doc says, it's literally just a small table that has the version number (e.g. 4.2.006), date, author, and description/list of changes made for that version. Every time I implement a change I give a new minor version number. Intermediate and major version numbers are down to the dev's opinion, the specific application, and what sort of change was made. Remember, numbers don't run out so don't be stingy with them

To change the database name (in Access 2010) you go: File > Options > Current Database > Application Title.
E.g. MyLittleDatabase v4.2.006
I find this a simple and easy way to keep a version number attached to the db.

Stormin is offline   Reply With Quote
Reply

Tags
access database , crashes , decompile , vba access 2010

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exteranl HD / Thumb Drive Dick7Access Hardware Questions and Answers 5 08-27-2015 07:06 PM
Does Decompile slow Queries? RogerCooper General 3 02-18-2015 04:27 AM
Question Decompile mcgilla General 2 08-10-2012 07:29 PM
runtime access97 on thumb drive? jmurphy General 6 12-05-2005 07:30 PM
Thumb drive KenHigg General 1 07-08-2005 11:01 AM




All times are GMT -8. The time now is 12:04 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World