Hi:
I have two Access databases. The backend database (BE.mdb) is on a network drive (L The Front end (FE.mdb) is located at users' workstations on local drives (C. I am trying to use Windows task scheduler to run a Macro (Scheduled1) in FE.mdb to update some tables in BE.mdb. It only works when I instruct the task scheduler to run the macro every time a user logs onto his workstation or at a specific time everyday. However, the second option will only work when the user is already logged into the computer. I want the system to do a daily update in the background when the user is logged off. So far, everytime I try this, it doesn't work, and the workstation creates an .ldb file. I thought the problem might be that you need to instruct Windows to map to the network drive before running the macro, but it still won't work. Any help will be appreciated. Below is some code. IMS Back End is the folder that contains BE.mdb in Drive L:
Dim MyDriveName As String
MyDriveName = "\\dhsrlcsrv01\vrdlgroups\VRDLGROUP\IMS Back End (L)"
'------------------------------------------------------------
'- map drive
On Error Resume Next ' DRIVE MAY BE MAPPED ALREADY
Set MyDrive = CreateObject("WScript.Network")
MyDrive.MapNetworkDrive "L:", MyDriveName
DoEvents
'--------------------------------------------------------------
'- error check
If Err.Number <> 0 Then
MsgBox (" Drive already mapped or not available ")
Else
End If
I have two Access databases. The backend database (BE.mdb) is on a network drive (L The Front end (FE.mdb) is located at users' workstations on local drives (C. I am trying to use Windows task scheduler to run a Macro (Scheduled1) in FE.mdb to update some tables in BE.mdb. It only works when I instruct the task scheduler to run the macro every time a user logs onto his workstation or at a specific time everyday. However, the second option will only work when the user is already logged into the computer. I want the system to do a daily update in the background when the user is logged off. So far, everytime I try this, it doesn't work, and the workstation creates an .ldb file. I thought the problem might be that you need to instruct Windows to map to the network drive before running the macro, but it still won't work. Any help will be appreciated. Below is some code. IMS Back End is the folder that contains BE.mdb in Drive L:
Dim MyDriveName As String
MyDriveName = "\\dhsrlcsrv01\vrdlgroups\VRDLGROUP\IMS Back End (L)"
'------------------------------------------------------------
'- map drive
On Error Resume Next ' DRIVE MAY BE MAPPED ALREADY
Set MyDrive = CreateObject("WScript.Network")
MyDrive.MapNetworkDrive "L:", MyDriveName
DoEvents
'--------------------------------------------------------------
'- error check
If Err.Number <> 0 Then
MsgBox (" Drive already mapped or not available ")
Else
End If