Results 1 to 2 of 2

Thread: [Access VBA] My File Version, Revision Number.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Anchorage, Alaska
    Posts
    545

    [Access VBA] My File Version, Revision Number.

    I was looking around on how to set/get the version number or Revision Number. I was unable to find this.

    Here are the ways I've found out about.
    • API Calls (GetFileVersionInfo)
    • Specific Filename format (I.E. Filename v##-##-####.mdb)
    • Application.CurrentProject.Properties


    API Calls (GetFileVersionInfo)
    Dave Sell posted a responce to one of our members back in 04 with the API call information.
    http://www.vbforums.com/showthread.php?t=295835


    Application.CurrentProject.Properties
    I created a GetMyVersion function, and a SetMyVersion function.

    GetMyVersion
    vb Code:
    1. Public Function GetMyVersion() As String
    2.     Dim TotalProps As Long
    3.     Dim Inc As Long
    4.    
    5.     TotalProps = Application.CurrentProject.Properties.Count
    6.  
    7.     For Inc = 0 To TotalProps - 1 Step 1
    8.         If Application.CurrentProject.Properties(Inc).Name = "Version" Then
    9.             GetMyVersion = Application.CurrentProject.Properties(Inc).Value
    10.             Exit Function
    11.         End If
    12.     Next Inc
    13.  
    14.     'if code gets here,
    15.     'No version information was found.
    16.     'or no properties at all were found.
    17.     Application.CurrentProject.Properties.Add "Version", "1.0.0"
    18.     GetMyVersion = "1.0.0"
    19. End Function

    SetMyVersion
    vb Code:
    1. Public Function SetMyVersion(ByVal MyVersion As String)
    2.     Dim TotalProps As Long
    3.     Dim Inc As Long
    4.    
    5.     TotalProps = Application.CurrentProject.Properties.Count
    6.    
    7.     For Inc = 0 To TotalProps - 1 Step 1
    8.         If Application.CurrentProject.Properties(Inc).Name = "Version" Then
    9.             Application.CurrentProject.Properties(Inc).Value = MyVersion
    10.             Exit Function
    11.         End If
    12.     Next Inc
    13.     'if code gets here,
    14.     'No version information was found.
    15.     'or no properties at all were found.
    16.     Application.CurrentProject.Properties.Add "Version", MyVersion
    17. End Function


    Specific Filename format (I.E. Filename v##-##-####.mdb)
    This simply entails getting the filename, getting the last X characters from the right side, and using that as the version number.

    vb Code:
    1. Public Function GetMyFNVersion(Optional ByVal MyVerLen As Integer = 10) As String
    2.     Dim LenOfName As Integer
    3.     Dim MyAppName As String
    4.     '10 for MyVerLen because ##.##.####
    5.     '## for Major Release
    6.     '## for Minor Release
    7.     '#### for Point Release
    8.    
    9.     MyAppName = Application.CurrentProject.Name
    10.     LenOfName = Len(MyAppName)
    11.     If LenOfName < MyVerLen Or MyVerLen = 0 Then
    12.         GetMyFNVersion = "ERROR in MyVerLen"
    13.         Exit Function
    14.     End If
    15.     GetMyFNVersion = Mid(MyAppName, (LenOfName - 4) - (MyVerLen - 1), MyVerLen)
    16. End Function

    Get Access' Version Number
    Most documents talked about getting access' version number/build. Here those are.

    Way 1
    vb Code:
    1. Function udfGetVersion() As String
    2.     '• 8.0  = Access 97
    3.     '• 9.0  = Access 2000
    4.     '• 10.0 = Access 2002(XP)
    5.     '• 11.0 = Access 2003
    6.     udfGetVersion = SysCmd(acSysCmdAccessVer)
    7. End Function

    Way 2
    vb Code:
    1. MsgBox "Version Number: " & Application.Version & vbNewLine & _
    2.         "Build Number: " & Application.Build
    Last edited by Hack; Oct 2nd, 2008 at 08:23 AM.
    Please RATE posts, click the RATE button to the left under the Users Name.

    Once your thread has been answered, Please use the Thread Tools and select RESOLVED so everyone knows your question has been answered.


    "As I look past the light, I see the world I wished tonight, never the less, sleep has come, and death shall soon follow..." © 1998 Jeremy J Swartwood

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [Access VBA] My File Version, Revision Number.

    Moved To The CodeBank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width