Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Updating Frontend when changes made 6

Status
Not open for further replies.

JARE

Technical User
Jul 27, 2000
50
US
What is the best way of going about updating an access
frontend? is there a way in access to automatically
update the frontend when the user starts access?
For example if I make a change to the front end I want
the database to automatically update itself without
having to email everyone the new front end. [sig][/sig]
 
Wemeier

I am not great at bat file commands. Can you post your bat file?



 
Sure! Here's the code I use to create and execute the .bat file:

Public Sub UpdateDatabaseVersion(strDatabaseName As String, strLocalPath As String, strMasterPath As String)
' Update the current database with a newer version by creating a batch file that will
' overlay the current database with the newer database and restart the database.

Input: strDatabaseName = the name of the database (without any path information)
strLocalPath = the path of the current database
strMasterPath = the path of the new database

Dim strAccessDir As String ' where MS-Access is located on the user's PC
Dim strLDBName As String

On Error GoTo UpdateDatabaseVersion_Err

' Get the location of MS-Access on the local PC
strAccessDir = SysCmd(acSysCmdAccessDir)

' Create the name of the LDB file that matches the local database that is being replaced
' (This is needed to make sure the database is closed before copying over it.

strLDBName = strDatabaseName
If InStr(strLDBName, ".") = 0 Then
strLDBName = strLDBName & ".ldb"
Else
Do While Right$(strLDBName, 1) <> &quot;.&quot;
strLDBName = left$(strLDBName, Len(strLDBName) - 1)
Loop
strLDBName = strLDBName & &quot;ldb&quot;
End If

' Build a new batch file in the same directory as the current database
Open strLocalPath & &quot;UPDTVER.BAT&quot; For Output As #1
Print #1, &quot;:Loop&quot;
Print #1, &quot;IF EXIST &quot; & conDoubleQuote & strLocalPath & strLDBName & conDoubleQuote & &quot; GOTO Loop&quot;
Print #1, &quot;COPY &quot; & conDoubleQuote & strMasterPath & strDatabaseName & conDoubleQuote & &quot; &quot; & conDoubleQuote & strLocalPath & strDatabaseName & conDoubleQuote
Print #1, conDoubleQuote & strAccessDir & &quot;Msaccess.exe&quot; & conDoubleQuote & &quot; &quot; & conDoubleQuote & strLocalPath & strDatabaseName & conDoubleQuote
Print #1, &quot;DEL &quot; & conDoubleQuote & strLocalPath & &quot;UPDTVER.BAT&quot; & conDoubleQuote
Close #1

' Invoke the batch file
Shell strLocalPath & &quot;UPDTVER.BAT&quot;, vbHide

' Quit this database
DoCmd.Quit
UpdateDatabaseVersion_Exit:
Exit Sub

UpdateDatabaseVersion_Err:
MsgBox Err.description
Debug.Print Err.description
Debug.Print &quot;Could not check for newer version&quot;
Resume UpdateDatabaseVersion_Exit

End Sub

What this coding does is build a .bat file that copies the database from the Master path to the Source path and restarts the database. It then executes the .bat file and quits the current (old version of the) database.

[shadeshappy] Cruising the Information Superhighway
[sub] (your mileage may vary)[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top