Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Harrow, UK
    Posts
    53

    Unanswered: I want to put a version number on a form

    I want to display a version number on a form. I'd like this numer to automatically update whenever a change is made to the database (the front end, not to the data).

    I'd quite like the format x.nnn where I set and change for big changes x and nnn is just an incremental counter.

    Any suggestions?
    Thank you,
    James

  2. #2
    Join Date
    Aug 2003
    Posts
    29

    for Access 2002

    Hi James;

    This should work with Access 2002. I dont think it will work with earlier versions.


    Suggestion;

    Create a table "tblFormVersions"
    Field 1 = FormName
    Field 2 = ModifiedDate
    Field 2 = PatchVersion

    Enter the appropriate data to initialize the table, example;

    Record 1 FormName ModifiedDate PatchVersion
    Clients 0
    Vendors 0


    1. Add a textbox (Unbound) "txtVersion" to each of the forms.
    Add a textbox (Unbound,not visible) "txtModDate" to each of the forms.


    2. Add this code to the On Load trigger of your forms.

    '-------------
    Dim acobjLoop As AccessObject
    Dim PatchVersion As Integer

    For Each acobjLoop In CurrentProject.AllForms
    With acobjLoop
    If acobjLoop.Name = {MyFormName} Then
    Call UpdateVersion(FormName,.DateModified, PatchVersion)
    If FormName <> "Error" Then
    Me!txtVersion = 1 & "." & PatchVersion
    Me!txtModDate = acobjLoop.DateModified
    Exit Sub
    Else
    Me!txtVersion = ""
    Exit Sub
    End If
    End If

    End With
    Next acobjLoop
    '-------------


    3. Create a Module "Version"

    4. Add to the module a function

    Public Function UpdateVersion(TheFormName, ModDate As Date, Patch As Integer)
    Dim rs As Recordset
    Dim strSql As String
    Dim db As Database: Set db = CurrentDb

    strSql = "Select * from tblFormVersions where FormName = '" & TheFormName & "'"
    Set rs = db.OpenRecordset(strSql)
    If rs.RecordCount = 0 Then
    MsgBox "Form not found!", vbCritical
    FormName = "Error"
    Exit Function
    End If

    If ModDate > rs!ModifiedDate Or IsNull(rs!ModifiedDate) Then
    rs.Edit
    rs!ModifiedDate = ModDate
    rs!PatchVersion = rs!PatchVersion + 1
    rs.Update

    End If

    Patch = rs!PatchVersion
    rs.Close
    Set rs = Nothing
    End Function

  3. #3
    Join Date
    Aug 2003
    Posts
    29

    Adjust to previous reply

    When my reply was posted the following needs a clearer direction.

    Enter the appropriate data to initialize the table, example;

    Record 1 FormName ModifiedDate PatchVersion
    Clients 0
    Vendors 0

    -------------------------------------------------------
    What you need to do is enter your form names in the FormName column and a zero in the Patch Version column of the tblFormVersions.

Posting Permissions

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