Conernesto
asked on
Access VBA - Is there a way to tell when code was changed or if it hasn't been changed?
I am trying to find if there were any changes on some of my code from my 2015 database to my 2016 database. Or if I can tell based on a system date the last date code was modified. Is there a date/time option that can be used to track code changes?
Is there a way to tell the last date VBA code was changed?
Conernesto
Is there a way to tell the last date VBA code was changed?
Conernesto
ASKER
Is a name needed for the code you sent me? Please volunteer a name if needed.
d.Name - will display the name of the module.
ASKER
I entered the code per below. When I run the code I get asked for a name. What am I doing wrong?
Option Compare Database
Dim db As Database
Dim C As Container
Set db = CurrentDb()
Set C = db.Containers("Modules")
For Each d In C.Documents
Debug.Print d.Name, d.DateCreated, d.LastUpdated
Next d
End Sub
Option Compare Database
Dim db As Database
Dim C As Container
Set db = CurrentDb()
Set C = db.Containers("Modules")
For Each d In C.Documents
Debug.Print d.Name, d.DateCreated, d.LastUpdated
Next d
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am getting a compile error. Variable not defined and it's looking at For Each d
open your references and look for MISSING
uncheck and look for the available similar reference
do a Compact and repair
do a Debug >Compile
see which line will be highlighted for errors
uncheck and look for the available similar reference
do a Compact and repair
do a Debug >Compile
see which line will be highlighted for errors
ASKER
The line that is highlighted in yellow is "Sub getModuleStatus ()". I don't see anything missing in reference.
where did you place the codes?
you should put it in a regular module so you can run it for testing by clicking on the run icon from the vba window
you should put it in a regular module so you can run it for testing by clicking on the run icon from the vba window
ASKER
I created a new module. Do need to put the code in an existing Form? If yes where do I copy the code before the end?
ASKER
Do I copy the code to existing Code?
Add this alongside the other declarations.
Dim d As Object
Note I've used Object as I'm not 100% sure how d should be typed, probably as Document, or DAO.Document, at a guess.
ASKER
I added the line of code Dim d As Object. When I run the code nothing happens.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh, yeah this line
7: Dim d As Document
was omitted in my codes above.
7: Dim d As Document
was omitted in my codes above.
ASKER
Great, I can see the dates when I open the Immediate Window (Ctrl+G). I am not sure how to enter getModuleStatus in the window to print the information.
just placed the cursor inside the SUB and click Run (right arrow) from the Tool bar
ASKER
I can see the date created and date modified for each module. However the dates created and modified are the same for in each different module. see two examples below.
ModuleA 11/18/2016 11:27:30 AM 11/18/2016 11:27:30 AM
ModuleB 12/23/2014 1:54:15 PM 12/23/2014 1:54:15 PM
ModuleA 11/18/2016 11:27:30 AM 11/18/2016 11:27:30 AM
ModuleB 12/23/2014 1:54:15 PM 12/23/2014 1:54:15 PM
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My goal was to prove that no code changes had been done from a year ago.
ASKER
or to identify modules that had changes from an earlier database. For example my 2015 database vs my 2016 database.
I suggest that you use a third party tool from FMS
http://www.fmsinc.com/microsoftaccess/DatabaseCompare.html
http://www.fmsinc.com/microsoftaccess/DatabaseCompare.html
Dim db As Database
Dim C As Container
Set db = CurrentDb()
Set C = db.Containers("Modules")
For Each d In C.Documents
Debug.Print d.Name, d.DateCreated, d.LastUpdated
Next d