X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Automatically Copy New Access Front End For Your Users With A Simple Batch File, Any Version    
post Jul 11 2014, 11:03 PM

UtterAccess VIP
Posts: 7,387
Joined: 30-June 11

Although this technique found in the Code Archive will work, I have used similar Batch files early on in my career, it is only advisable to be deployed with a limited number of users. If you have a system with 40, 80 or 200 users all continuously copying the FE in this manner, it will unnecessarily tax the network to the point of breaking connections... I have seen numerous companies with slow networks early in the morning, already taxed by all their employees login into their computers at relatively the same time. Now add to that all of them needlessly copying FEs across the network. The result in certain infrastructures can be very painful.
The technique of validating the current version of the FE against the Server FE is still the best technique, even if it is more complex.
Go to the top of the page
post Jul 12 2014, 10:55 AM

UtterAccess VIP / UA Clown
Posts: 32,217
Joined: 21-January 04
From: LI, NY

Such a simplistic approach will work in limited situations. One major point it doesn't address is Trusted Locations. If you send the shortcut to a new user who does not have Trusted Locations setup, they will get security prompts.
Is Daniel noted, this will work when you have a limited number of network users.
Go to the top of the page
post Mar 31 2015, 12:37 PM

Posts: 1
Joined: 26-March 15

I use a slightly more sophisticated solution. Excuse my crude code. I created a small database with one form. The form has one button labeled "Start". When you click start it checks the local computer for a copy of the database. If it does not exist it copies one from the server. If it does it copies the version table from the local copy and calls it the Version_Table_Child and copies the version_table from the server copy and names it version_table_parent. If the parent version is larger than child it copies over the child. If not it opens the child. The user can copy their copy any where they want and continue using it to access the db. The administrator only needs to add a new version to force the user copy to be overwritten. Hope it helps someone. If any one has any recommendations for improvement they are welcome.

Jonathan Reb Hodgson

' Start_Form_Button_Click
Private Sub Start_Form_Button_Click()
On Error GoTo Start_Form_Button_Click_Err

Dim Parent_DB As String

Parent_DB = "\\Vwoachsvwa01\common\Pilot_Hall\150 Documentation System\Data\Pilot_Hall_Body_Documentation_System.accdb"
Local_Folder = "C:\Pilot_Hall_Body_Documentation_system\"
Local_File_Name = "Pilot_Hall_Body_Documentation_System.accdr"

'ImportDb (Parent_DB)
If Len(Dir(Local_Folder, vbDirectory)) = 0 Then MkDir Local_Folder

' Add Change Log To Backup Folder
If Dir(Local_Folder & Local_File_Name) = "" Then
    MsgBox "An update has been found. Updating the database will take at lease 20 seconds depending on network speed. Please do not close the program until complete. Thanks you."
    DoCmd.Hourglass True
    FileCopy Parent_DB, Local_Folder & Local_File_Name
    DoCmd.Hourglass False
    DeleteTable "Version_Table_Parent"
    DeleteTable "Version_Table_Child"
    DoCmd.TransferDatabase acImport, "Microsoft Access", Parent_DB, acTable, "Version_Table", "Version_Table_Parent"
    DoCmd.TransferDatabase acImport, "Microsoft Access", Local_Folder & Local_File_Name, acTable, "Version_Table", "Version_Table_Child"
    Dim db As DAO.Database
    Dim r1 As Recordset
    Dim r2 As Recordset
    Set db = CurrentDb
    Set rparent = db.OpenRecordset("Version_Table_Parent")
    Set rchild = db.OpenRecordset("Version_Table_Child")
    If rparent.Fields("Version_ID") > rchild.Fields("Version_ID") Then
        MsgBox "An update has been found. Updating the database will take at lease 20 seconds depending on network speed. Please do not close the program until complete. Thanks you."
        DoCmd.Hourglass True
        FileCopy Parent_DB, Local_Folder & Local_File_Name
        DoCmd.Hourglass False
    End If
End If

' Section of Code to Open Local DB
Dim dq As String
Dim strExe As String
Dim strMdb As String
Dim strRun As String
Dim WindowStyle As VbAppWinStyle
WindowStyle = vbMaximizedFocus
dq = """"

'Define var strExe; Miscosoft Access
strExe = "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"

'Define var strMdb; Project database location
strMdb = Local_Folder & Local_File_Name

'Define the entire statement to implement at Shell
strRun = dq & strExe & dq & " " & dq & strMdb ' & dq & " /runtime"

'strRun = dq & strExe & dq & " " & dq & strMdb & dq

'Run the code to open the project database
x = Shell(strRun, WindowStyle)

'Call Shell("'" & strExe & "' /A 'navpanes=0&toolbars=0' '" & strMdb & "'", vbNormalFocus)

'DoCmd.NavigateTo "acNavigationCategoryObjectType"

'DoCmd.RunCommand acCmdWindowHide




    Exit Sub

    MsgBox Error$
    Log_Error "Start_Form_Button_Click", Error$
    Resume Start_Form_Button_Click_Exit

End Sub
Go to the top of the page
Auntie Jack
post Jun 14 2017, 10:24 PM

Posts: 130
Joined: 10-March 10

Hi, I know there are already lots of tools in the bag for deploying databases from the network to the C and then starting them up.

For reasons discussed by other posters above I have always used a Launcher database similar to Reb and Scott.

However, for my current client I am using a bat file (don't ask). Bat files have a very serious limitation on this slow network: copy or xcopy take 20-30 seconds to copy a new version, so the user sees nothing happening during that time. I wanted a spinner or progress bar but such things are hard to come by in the bat world.

An alternative in Windows which has a progress bar (Esentutil) doesn't have a date argument to ensure that only the latest file is copied. And it won't overwrite.

Thanks to Dave Benham at dostips http://www.dostips.com/forum/viewtopic.php?t=6063 I have managed to cobble together his use of WMIC and my discovery of Esentutil (both available in Windows 7+) to give a progress bar during the copy. As you can see below, the result from his FileModTime enables deletion of the target file and initiation of the copy (Esentutil /y) only if the source file is newer. All in the one relatively short batch file. Yay. Not many people will need this, but if you do - enjoy.

@echo off

if not exist "%appdata%\ReportManager\" mkdir %appdata%\ReportManager

call :FileModTime "H:\Commercial Planning\Reporting\Report Management\Applications\DigitalReports.accdb" A
call :FileModTime "%appdata%\ReportManager\DigitalReports.accdb" B

rem echo a is %A%
rem echo b is %B%

set "diff=0"

if defined A if defined B set /a diff=A-B

if %diff% gtr 2 (
del "%appdata%\ReportManager\DigitalReports.accdb"
esentutl /y "H:\Commercial Planning\Reporting\Report Management\Applications\DigitalReports.accdb" /d %appdata%\ReportManager\DigitalReports.accdb /o)

Start %appdata%\ReportManager\DigitalReports.accdb

exit /b

:FileModTime File [TimeVar]
:: Computes the Unix time (epoch time) for the last modified timestamp for File.
:: The result is an empty string if the file does not exist. Stores the result
:: in TimeVar, or prints the result if TimeVar is not specified.
:: Unix time = number of seconds since midnight, January 1, 1970 GMT
setlocal disableDelayedExpansion
:: Get full path of file (short form if possible)
for %%F in ("%~1") do set "file=%%~sF"
:: Get last modified time in YYYYMMDDHHMMSS format
set "time="
for /f "skip=1 delims=,. tokens=2" %%A in (
'wmic datafile where name^="%file:\=\\%" get lastModified /format:csv 2^>nul'
) do set "ts=%%A"
set "ts=%ts%"
:: Convert time to Unix time (aka epoch time)
if defined ts (
set /a "yy=10000%ts:~0,4% %% 10000, mm=100%ts:~4,2% %% 100, dd=100%ts:~6,2% %% 100"
set /a "dd=dd-2472663+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4"
set /a "ss=(((1%ts:~8,2%*60)+1%ts:~10,2%)*60)+1%ts:~12,2%-366100-%ts:~21,1%((1%ts:~22,3%*60)-60000)"
set /a "ts=ss+dd*86400"
:: Return the result
endlocal & if "%~2" neq "" (set "%~2=%ts%") else echo(%ts%
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    14th July 2020 - 04:18 AM