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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying mde/mdb from network to client automatically

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I use a Visual Basic 6 program that runs as a short cut on the client's desktop. They click it and get the latest update copied to their computer and opens the database. The first thing you need to do in VB is create a reference to Microsoft Scripting Runtime. Then run this code, create an executable and create a short cut on the client's desktop of the executable. The code is commented to show what's going on. I also add a label on the form to show that a file was copied.

Const Network As String = "E:\AccessDB\Foreclosure.mde"
Const Client As String = "D:\AccessDB\Foreclosure1.mde"
Dim fso As FileSystemObject

Private Sub Form_Load()

'Instantiate file scripting object
Set fso = New FileSystemObject

'Copy file to client if no file exists on client
If fso.FileExists(Client) = False Then
fso.CopyFile Network, Client
Label1 = Client & " new file copied to client folder."


'Copy file latest update to client if file exists
'and date last modified on network is greater than client
ElseIf fso.GetFile(Network).DateLastModified > _
fso.GetFile(Client).DateLastAccessed Then
fso.CopyFile Network, Client, True
Label1 = Client & " new update copied to client folder."
End If

'Dereference file scripting object
Set fso = Nothing

'Open access front end with maximized focus
Shell "D:\Program Files\MicrosoftOffice\Office\MSAccess.exe D:\AccessDB\Foreclosure1.mde", vbMaximizedFocus

'End program
End

End Sub
 
Change Label1 to msgbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top