UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Getfileversion Gets Me The File Version, How Do I Set It For A File?, Any Version    
 
   
cocoflipper
post Dec 1 2011, 03:58 PM
Post #1

UtterAccess Guru
Posts: 890
From: Denver - CO



I'm trying to copy over an Access file if it has been changed. I'm using a script and the filesystem object

Problem with using Data Modified is that if I change a table in the Access file (not the code), the Date Modified gets updated, and hence the user would be updating every time.

The Date Created was an option, but this seems to be static once the file exists in the folder (doesn't get updated, even if deleted then readded).

I moved onto File Version of the file, thinking this might be an option. I can use GetFileVersion to find what it is, but I can't seem to find out where to change it for my Access file. Is this through the Access applicaiton? Some property on the file properties area?

Any help is appreciated!
Go to the top of the page
 
+
Doug Steele
post Dec 1 2011, 05:35 PM
Post #2

UtterAccess VIP
Posts: 17,622
From: Don Mills, ON (Canada)



If I'm understanding what you're trying to do, you need to add a Database Property, and then use DAO (not GetFileVersion) to read that property's value.
Go to the top of the page
 
+
cocoflipper
post Dec 1 2011, 06:05 PM
Post #3

UtterAccess Guru
Posts: 890
From: Denver - CO



Can't use DAO. I'm not in Access; I'm running a script (.vbs) on a server over Citrix in order to move the file (Access file in this case). File assessment all has to be done before Access fires up.

Thanks for any suggestions.
Go to the top of the page
 
+
Doug Steele
post Dec 1 2011, 07:03 PM
Post #4

UtterAccess VIP
Posts: 17,622
From: Don Mills, ON (Canada)



Why are you posting to Visual Basic 6 or earlier then?

I know I've successfully used DAO with VBScript in the past, although to be honest I can't get an example to work. See whether you have any better luck with the samples in Chapter 2 of the DAO Object Model. See, too, what Alex Dybenko has in How to get reference to DBEngine
Go to the top of the page
 
+
cocoflipper
post Dec 2 2011, 12:13 AM
Post #5

UtterAccess Guru
Posts: 890
From: Denver - CO



OK - I'll post this in another area then.
Go to the top of the page
 
+
datAdrenaline
post Dec 2 2011, 11:06 AM
Post #6

UtterAccess Editor
Posts: 15,967
From: Northern Virginia, USA



>> I'm running a script (.vbs) <<

That will not stop you from reading a DAO.Database property on an MDB/ACCDB file. But first read this post about the difference between User properties and Database properties. I will assume that for easy maintenance you will use the properties that you can access through the Access UI (in A2003: File | Database Properties; in A2007: Office Icon | Manage | Database Properties; in A2010: File | Info | View and edit database properties {its the link over to the right of the page}), which are known as User properties.

The following vbscript will get the value of the User property named "udReleaseVersion" which is defined as Text (of course your file name would have to change to what is appropriate):

CODE
'Read a DAO.Database property with VBScript
Dim strReleaseVersion
Dim strDbFilename
Dim jetEngine
Dim workSpace
Dim db

'Set up the file name
strDbFilename = "C:\someFolder\someFile.mdb"

'Create and prepare an instance of the JET/ACE db engine to do its thing.
'Use: DAO.DBEngine.120 for the ACE 12.0 engine (Access 2007/A2010)
'Use: DAO.DBEngine.36 for JET 4.0 engine (Access 2000 and higher -- IIRC)
Set jetEngine = CreateObject("DAO.DBEngine.120")
Set workSpace = jetEngine.CreateWorkspace("#DEFAULT#", "Admin", "")
Set db = workSpace.OpenDatabase(strDbFilename)

'Read the property.
strReleaseVersion = db.Containers("Databases").Documents("UserDefined").Properties("udReleaseVersion")

'Display the Property so you know it has been read
MsgBox strReleaseVersion

'Clean up
db.Close
workSpace.Close
Set jetEngine = Nothing


If you want to use a Database property, I would suggest that you look at the code I posted in this post that helps you manage both UserDefined properties (the ones you can add/modify from the Access UI) and Database properties (the ones you can't by default). Then your vbscript would just have a single line to change, then one where you set strReleaseVersion

CODE
strReleaseVersion = db.Properties("dbReleaseVersion")


Rememeber in this sample, I had to create the property, whether UserDefined or Database, named "udReleaseVersion" ("dbReleaseVersion" respectively). I chose those names because "Version", "AccessVersion" is already a Database property. I add the prefixes just in case the Access team decides to add UserDefine properties or Database properties in the future, they likely won't step on the ones I add.



Hope that helps!




Go to the top of the page
 
+
cocoflipper
post Dec 2 2011, 02:15 PM
Post #7

UtterAccess Guru
Posts: 890
From: Denver - CO



Thanks for this explanation, Brent. I am familiar with both types of properties. On one application, I use the create and use a db property "AppLicense" - CurrentDb.Properties![AppLicense] - to assess whether a uer has a license, and on another app I use a user-defined property "UpdateVersion" - CurrentDb.Containers("Databases").Documents("UserDefined").Properties("UpdateVersion") - to get some versioning info. I am not familiar enough using scripts as I code mainly in the VBA window in a contained environment (the Access app that I am working on), but scripting is similar enough. I will see about utilizing the user property - UpdateVersion - in the app in question, then look through your code to add things to my script in order to assess the file for updating (which means that I'll have to assess a user property from both files for this particular situation).

My original question related to the file properties that are accessible using the file system object (Date Created, Date Modified, File Version). This seemed to be an easily accessible item from a script where I did not have to scrape down too many layers or worry about versioning issues. There seems to be a "file version" field for every file, and you can read it in the script using GetFileVersion, but there does not seem to be a way to write to this field to edit it, either using the file system object or the windows file properties dialog box. Perhaps this field is only avaiable to dlls, as I only see this field filled out for these types of files. I was trying to make it easier (not having to worry about DAO.DBEngine versions to this or that version of Access), but at this point I will take what I can get.

Thanks for the insight.
Go to the top of the page
 
+
datAdrenaline
post Dec 2 2011, 03:48 PM
Post #8

UtterAccess Editor
Posts: 15,967
From: Northern Virginia, USA



I am pretty sure the File Version property is created when the file (DLL) is assembled (Built into the DLL from the code). I say that because when I develop with C# I control that value and it is embedded in the DLL somehow by Visual Studio.

I hope the db property concept fits your needs!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 07:20 AM