Auto update front-end (1 Viewer)

Mr. SLP

Registered User.
Local time
Today, 17:34
Joined
Dec 23, 2017
Messages
56
I'm trying to setup a DB on the network drive at work and I would like for each individual's local copy of the FE to automatically update to the newest version upon opening. I found this thread...
https://access-programmers.co.uk/forums/showthread.php?t=265491

it seems to be what I need but I cant figure out how to implement it, and it looks like I'm not the only 1. Any advice on how to accomplish this/use the code listed in this thread?
 

Ranman256

Well-known member
Local time
Today, 18:34
Joined
Apr 9, 2015
Messages
4,339
i have a form showing all my users.
when i click the disribute button ,The code sends a copy of the database to each.

Code:
Public Sub Copy2All()

  ' ShowMsg "Copying..."
  
    vSrc = CurrentDb.Name  ' getCfgProdDb()

            'get extension name
    vExt = Mid(CurrentDb.Name, InStrRev(CurrentDb.Name, "."))
        
  'get all the users folders from the table in the form
        With Me.Recordset
             .MoveFirst
             While Not .EOF
                    'pack up both name and path
                 vDir = .Fields("folder").Value
                 vNam = .Fields("UserName").Value
                 vWord = vNam & kCHR & vDir
                 colDirs.Add vWord
                .MoveNext
             Wend
        End With

           'go thru the collection and copy to the user
        For Each vWord In colDirs
               'break up name@dir
            i = InStr(vWord, kCHR)
            If i = 0 Then
              vNam = txtName
              vDir = txtDir
            Else
                vNam = Left(vWord, i - 1)
                vDir = Mid(vWord, i + 1)
            End If
            
            getDirName vSrc, X, f
            vTarg = FixDir(vDir) & f
            
           'ShowMsg "Copying to " & vbCrLf & vNam      'put this message on the form
            
            Copy1File vSrc, vTarg
skipIt:
        Next
           MsgBox "Done", , "Distribution"

Set colDirs = Nothing
End Sub



'given filepath, passes back: Dir name , filename
Public Sub getDirName(ByVal psFilePath, ByRef prvDir, Optional ByRef prvFile)
    'psFilePath: full file path given
    'prvDir : directory name output
    'prvFile: filename only output
Dim i As Integer, sDir As String

i = InStrRev(psFilePath, "\")
If i > 0 Then
  prvDir = Left(psFilePath, i)
  prvFile = Mid(psFilePath, i + 1)
  If Asc(Mid(prvFile, Len(prvFile), 1)) = 0 Then RemoveLastChr prvFile
End If
End Sub

Public Sub Copy1File(ByVal pvSrc, ByVal pvTarg)
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile pvSrc, pvTarg
Set FSO = Nothing
End Sub
 

Minty

AWF VIP
Local time
Today, 23:34
Joined
Jul 26, 2013
Messages
10,367
What part of it is stumping you - I use almost identical code to the one shown without any issues.

You need to have a local table in the front end with the local current version number in it and a shared table in the BE with the Actual Live version number. Compare the two and if different run the batch file to upload and then open the new version.

When you release a new version you update the version number in the master BE table.

Or a variation on this theme.
 

isladogs

MVP / VIP
Local time
Today, 23:34
Joined
Jan 14, 2017
Messages
18,209
I don't use that code so I can't comment on it.

My approach is as follows:
1. When admin users load my apps, a routine automatically checks whether a new version is available from my website. If so, a message is displayed with a link to the relevant webpage

2. The program admin downloads the file & performs any associated actions as in the supplied upgrade instructions.
When done, the updated files are copied to an Upgrade folder on the network

3. When other users open the FE, it checks whether a newer version is available in the upgrade folder and if so, copies the files to the user's computer
The whole process is very fast as it uses Windows API calls

4. If the utility used to perform this check is itself updated, the new version is copied across to the user PC in the same way.

For more details see the attached PDF file
 

Attachments

  • UpdatingAccessFE.zip
    500.8 KB · Views: 593

Mr. SLP

Registered User.
Local time
Today, 17:34
Joined
Dec 23, 2017
Messages
56
What part of it is stumping you - I use almost identical code to the one shown without any issues.

You need to have a local table in the front end with the local current version number in it and a shared table in the BE with the Actual Live version number. Compare the two and if different run the batch file to upload and then open the new version.

When you release a new version you update the version number in the master BE table.

Or a variation on this theme.



I guess my issue, as dumb as it might be, is knowing where to put the code. At first I read it that all of the code needed to be entered into a module. However, that doesn’t make since because I would think I would need something to trigger the code. So, I guess the question is, the module obviously needs to be put in a module but where does the rest of it need to go?


Sent from my iPhone using Tapatalk
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:34
Joined
Feb 19, 2002
Messages
43,203
I don't use any code at all. I use a batch file
Code:
md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" c:\DwgLog
c:\DwgLog\DrawingLog.accdb
The batch file is located on the server in the same folder as the master copy of the FE. Each user has a shortcut on their desktop. When they run the shortcut, it runs the batch file which copies the file. The md line makes the directory I want the file to be placed in. There is no error if the diretory already exists which means that even new users can use the shortcut. The second line deletes the existing copy. Again, there is no error raised if the file doesn't exist. The third line copies the file from the server and the fourth line opens the database.

I have a Citrix version also should you need that one.
Code:
md %USERPROFILE%\DwgLog
del %USERPROFILE%\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" %USERPROFILE%\DwgLog
%USERPROFILE%\DwgLog\DrawingLog.accdb
It is essentially the same except that rather than hardcoding the local drive, it uses the path associated with the user profile.

When using CITRIX, sometimes you need to be very firm with the people doing the setup. They don't understand that EVERY user needs a SEPARATE copy of the FE. They always want everyone to open the same database.
 

bastanu

AWF VIP
Local time
Today, 15:34
Joined
Apr 13, 2010
Messages
1,402
Please feel free to download and use my free Access db launcher from forestbyte.com/MS Access Utilities. It is very easy to setup and I provided a small user guide to show its usage.

Cheers,
Vlad
 

bobalston

New member
Local time
Today, 17:34
Joined
Apr 17, 2012
Messages
4
I don't use any code at all. I use a batch file
Code:
md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" c:\DwgLog
c:\DwgLog\DrawingLog.accdb
The batch file is located on the server in the same folder as the master copy of the FE. Each user has a shortcut on their desktop. When they run the shortcut, it runs the batch file which copies the file. The md line makes the directory I want the file to be placed in. There is no error if the diretory already exists which means that even new users can use the shortcut. The second line deletes the existing copy. Again, there is no error raised if the file doesn't exist. The third line copies the file from the server and the fourth line opens the database.

I have a Citrix version also should you need that one.
Code:
md %USERPROFILE%\DwgLog
del %USERPROFILE%\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" %USERPROFILE%\DwgLog
%USERPROFILE%\DwgLog\DrawingLog.accdb
It is essentially the same except that rather than hardcoding the local drive, it uses the path associated with the user profile.

When using CITRIX, sometimes you need to be very firm with the people doing the setup. They don't understand that EVERY user needs a SEPARATE copy of the FE. They always want everyone to open the same database.
@Pat Hartman Do you ever add logic to handle if you cannot access the fe site but want to leave the old version usable?

Bob
 

tonez90

Registered User.
Local time
Tomorrow, 08:04
Joined
Sep 18, 2008
Messages
42
One area you need to careful about is the ability to "Roll Back" the front ends in case there is an issue that just rolls out. I personally used a table in the backend which has this sort of setting in it. I also developed two bat files one to update and then one to rollback. These could be coded into the front end if needed but generally much easier to put in the FE directory. In this way any permissions the user has will help alleviate any networking permissions.
I start the database and use a function called "check_version" which essentially looks at the backend (settings) and front end variable and compares the two if and if greater then update using a function "update" which uses the shell process to run the bat file (i.e. set the variable to the bat file location usually in a network location all has access to. I found this to be effective on network drive over large distances (different offices in different states and cities).
I would provide some code but I will need to extract it from the DB as it is entrenched in the auto startup routines.

Cheers
Tonez
 

bastanu

AWF VIP
Local time
Today, 15:34
Joined
Apr 13, 2010
Messages
1,402
My free launcher mentioned in post # 7 would create a backup of the existing front-end (in a subfolder of the fe's location), so any user can revert to their previous version or import any modified objects (for power users that would create their own queries/reports).

Cheers,
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:34
Joined
Feb 19, 2002
Messages
43,203
tone, the script is extremely simplistic and intended for internal use. If you are having people go to an external website for the download, I would suggest using a more robust script that downloads the file first, perhaps to a different folder and then only continuing if the download was successful.
 

Users who are viewing this thread

Top Bottom