Decompile : general rule of thumb? (1 Viewer)

vent

Registered User.
Local time
Today, 12:45
Joined
May 5, 2017
Messages
160
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:

moke123

AWF VIP
Local time
Today, 12:45
Joined
Jan 11, 2013
Messages
3,852
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.
 

BigHappyDaddy

Coding Monkey Wanna-Be
Local time
Today, 09:45
Joined
Aug 22, 2012
Messages
205
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.
 

vent

Registered User.
Local time
Today, 12:45
Joined
May 5, 2017
Messages
160
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?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:45
Joined
Feb 28, 2001
Messages
26,999
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.
 

moke123

AWF VIP
Local time
Today, 12:45
Joined
Jan 11, 2013
Messages
3,852
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".
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:45
Joined
Feb 19, 2013
Messages
16,553
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.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 12:45
Joined
Jun 20, 2003
Messages
6,423
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)>
 

vent

Registered User.
Local time
Today, 12:45
Joined
May 5, 2017
Messages
160
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:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:45
Joined
Feb 28, 2001
Messages
26,999
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.
 

Stormin

Nawly Ragistarad Usar
Local time
Today, 16:45
Joined
Dec 30, 2016
Messages
76
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.
 

vent

Registered User.
Local time
Today, 12:45
Joined
May 5, 2017
Messages
160
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"?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:45
Joined
Feb 28, 2001
Messages
26,999
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.
 

Stormin

Nawly Ragistarad Usar
Local time
Today, 16:45
Joined
Dec 30, 2016
Messages
76
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.
 

Users who are viewing this thread

Top Bottom