# VBForums CodeBank > CodeBank - Other >  [Access VBA] My File Version, Revision Number.

## rack

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:
Public Function GetMyVersion() As String
    Dim TotalProps As Long
    Dim Inc As Long
    
    TotalProps = Application.CurrentProject.Properties.Count
     For Inc = 0 To TotalProps - 1 Step 1
        If Application.CurrentProject.Properties(Inc).Name = "Version" Then
            GetMyVersion = Application.CurrentProject.Properties(Inc).Value
            Exit Function
        End If
    Next Inc
     'if code gets here,
    'No version information was found.
    'or no properties at all were found.
    Application.CurrentProject.Properties.Add "Version", "1.0.0"
    GetMyVersion = "1.0.0"
End Function

*SetMyVersion*

vb Code:
Public Function SetMyVersion(ByVal MyVersion As String)
    Dim TotalProps As Long
    Dim Inc As Long
    
    TotalProps = Application.CurrentProject.Properties.Count
    
    For Inc = 0 To TotalProps - 1 Step 1
        If Application.CurrentProject.Properties(Inc).Name = "Version" Then
            Application.CurrentProject.Properties(Inc).Value = MyVersion
            Exit Function
        End If
    Next Inc
    'if code gets here,
    'No version information was found.
    'or no properties at all were found.
    Application.CurrentProject.Properties.Add "Version", MyVersion
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:
Public Function GetMyFNVersion(Optional ByVal MyVerLen As Integer = 10) As String
    Dim LenOfName As Integer
    Dim MyAppName As String
    '10 for MyVerLen because ##.##.####
    '## for Major Release
    '## for Minor Release
    '#### for Point Release
    
    MyAppName = Application.CurrentProject.Name
    LenOfName = Len(MyAppName)
    If LenOfName < MyVerLen Or MyVerLen = 0 Then
        GetMyFNVersion = "ERROR in MyVerLen"
        Exit Function
    End If
    GetMyFNVersion = Mid(MyAppName, (LenOfName - 4) - (MyVerLen - 1), MyVerLen)
End Function

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

Way 1

vb Code:
Function udfGetVersion() As String
    ' 8.0  = Access 97
    ' 9.0  = Access 2000
    ' 10.0 = Access 2002(XP)
    ' 11.0 = Access 2003
    udfGetVersion = SysCmd(acSysCmdAccessVer)
End Function

Way 2

vb Code:
MsgBox "Version Number: " & Application.Version & vbNewLine & _
        "Build Number: " & Application.Build

----------


## Hack

_Moved To The CodeBank_

----------

