Results 1 to 4 of 4
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    Update Database version

    Hi,

    I am attempting to write a code that will:
    1) copy the current database from the network to their C:\drive so they can access it from there going forward
    2) check for a new version of the database and update to the new version



    Currently, it will run the CERT.bat file to create/copy the database but it doesn't recognize to update it to the new version.

    I have the following:

    Code:
    Private Sub Form_Open(Cancel As Integer)
        On Error GoTo ErrorHandler
        Dim sPath As String
        sPath = CurrentProject.Path
        MsgBox sPath, vbOKCancel
        Me.Caption = "- Cost Estimating Request Tool v" & Version
        'TODO Update app title based on 'Version'
       
        If IsACCDE Then
    '         MsgBox "Made It" 'DEBUG
            
            DoCmd.SelectObject acTable, , True
            DoCmd.ShowToolbar "Ribbon", acToolbarNo
            DoCmd.RunCommand acCmdWindowHide
            Application.SetOption "Show Status Bar", False
                'Check if running from Network location (currentproject.path)
            If InStr(1, sPath, NetCheck, vbTextCompare) > 0 Then
                'Case yes - install to c/estimating w/desktop shortcut
                MsgBox "You are currently trying to run the Estimating Request Tool from the Network." & vbNewLine & " A local version will be installed, and a shortcut copied to your Desktop.", _
                    vbCritical + vbOKOnly, "Install Estimating Request Tool"
                UpdateApplication
            Else
                'case no - check version
                Dim sVer As Double
                sVer = CDbl(DLookup("Version", "tbl_Global_Settings", "App='EstimateRequest'"))
                If sVer > Version Then
                     MsgBox "A new version of the Request Tool is available." & vbNewLine & "The update will be automatically installed to your computer.", _
                    vbCritical + vbOKOnly, "Estimating Request Tool: Update Needed"
                    UpdateApplication
                End If
            End If
        End If
    Exit Sub
     
    ErrorHandler:
    MsgBox "Error: " & Err.Number & ", " & Err.Description
    Exit Sub
     
    End Sub
    These are in a Module

    Code:
    Public Const Version As Double = 2.8

    Code:
    Public Sub UpdateApplication() 'Byval NewInstall as boolean
        'if true then
        ' case 1 new install current code works,
        ' case 2 update from local copy - need to close and run batch file to copy and restart.
       
        Dim DestPath As String
        DestPath = "C:\Estimating\Request Tool"
       
        If Dir("c:\Estimating", vbDirectory) = "" Then
            MkDir "C:\Estimating"
        End If
        If Dir("c:\Estimating\Request Tool", vbDirectory) = "" Then
            MkDir "C:\Estimating\Request Tool"
        End If
       
        sPath = DLookup("InstallSourcePath", "tbl_Global_Settings", "App='EstimateRequest'")
        
        Dim FSOLibrary As Object
        Dim FSOFolder As Object
        Dim FSOFile As Object
    
         'Set all the references to the FSO Library
         Set FSOLibrary = CreateObject("Scripting.FileSystemObject")
         Set FSOFolder = FSOLibrary.GetFolder(sPath)
         Set FSOFile = FSOFolder.Files
         
         'Use For Each loop to loop through each file in the folder
         For Each FSOFile In FSOFile
             Debug.Print FSOFile.Name
             FSOLibrary.CopyFile sPath & "\" & FSOFile.Name, DestPath & "\" & FSOFile.Name
             DoEvents
         Next
       
         DestPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\Cost Estimating Request Tool.lnk"
         If Dir("C:\Estimating\Request Tool\Cost Estimating Request Tool.lnk") <> vbNullString Then
            FSOLibrary.CopyFile "C:\Estimating\Request Tool\Cost Estimating Request Tool.lnk", DestPath, True
         End If
         'Release the memory
         Set FSOLibrary = Nothing
         Set FSOFolder = Nothing
         Set FSOFile = Nothing
       
         'Dim sAppPath As String, retval
         'sAppPath = Application.SysCmd(acSysCmdAccessDir) & "msaccess.exe"
         'retval = Shell(sAppPath & " " & vbDoubleQuote & "C:\Estimating\Request Tool\Cost Estimating Request Tool.accde" & vbDoubleQuote
        If Dir("C:\Estimating\Request Tool\CERT.bat") <> vbNullString Then
            Shell ("C:\Estimating\Request Tool\CERT.bat")
        Else
            WriteBATFile
        End If
       
        DoEvents
        DoCmd.Quit acQuitSaveNone
    End Sub

    Code:
    Private Sub WriteBATFile()
        Dim fs As Object, a As Object
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set a = fs.CreateTextFile("C:\Estimating\Request Tool\CERT.bat", True)
        Debug.Print "START /B " & vbDoubleQuote & "Access" & vbDoubleQuote & " " & vbDoubleQuote & "C:\Estimating\Request Tool\Cost Estimating Request Tool.accde" & vbDoubleQuote
       
        a.WriteLine ("START /B " & vbDoubleQuote & "Access" & vbDoubleQuote & " " & vbDoubleQuote & "C:\Estimating\Request Tool\Cost Estimating Request Tool.accde" & vbDoubleQuote)
        a.WriteLine ("EXIT")
        a.Close
        Shell ("C:\Estimating\Request Tool\CERT.bat")
    'START /B "Access" "C:\Estimating\Request Tool\Cost Estimating Request Tool.accde"
    'EXIT
     
    End Sub

  2. #2
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    Quick Update - Reading this https://btabdevelopment.com/free-access-tools/

    Just in case it gets referenced, it doesn't open the files

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Some people just copy the DB each time using a shortcut and a batch file.
    I used Bob Larsens updater https://www.access-programmers.co.uk...tility.159823/ in the past

    Vlad @Gicu also has an updater, no doubt he will post a link soon.
    I have just found it I believe. http://forestbyte.com/ms-access-util...G3a5bsYECzLvNI
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    I was able to download the FBA_DB_Launcher but not any code.

    I am working through Bob Lasen's which I believe is how the original code was based off

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-24-2021, 07:58 AM
  2. Replies: 7
    Last Post: 02-05-2018, 08:14 PM
  3. Update error (3144) on French Access version
    By Euler in forum Programming
    Replies: 13
    Last Post: 02-04-2015, 02:41 PM
  4. Automate Front End update when version doesn't match
    By brharrii in forum Programming
    Replies: 4
    Last Post: 12-13-2013, 09:30 AM
  5. Access Version update
    By newwales in forum Access
    Replies: 0
    Last Post: 11-02-2011, 05:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums