Malcolmneill
Registered User.
- Local time
- Today, 14:20
- Joined
- May 7, 2011
- Messages
- 17
I am probably being dumb, but I can't execute a BAT file from within Access. The file will execute manually from any location correctly, I just can't make it work in either a macro or within VBA. I probably don't understand the way to do it. My code is simple, perhaps too simple:
Function Save_DB()
Dim RetVal As Long
MsgBox "saving DB", vbOKOnly
On Error Resume Next
RetVal = Shell("D:\Access DB\OCS Backup.bat", 1)
MsgBox "saved DB", vbOKOnly
End Function
The objective here is to simply copy the linked database file to a backup directory automatically as the user exits the application. The messages display so I know it's finding the function but the DOS command box never opens, there's a pause to stop it closing. Can someone advise me please.
Function Save_DB()
Dim RetVal As Long
MsgBox "saving DB", vbOKOnly
On Error Resume Next
RetVal = Shell("D:\Access DB\OCS Backup.bat", 1)
MsgBox "saved DB", vbOKOnly
End Function
The objective here is to simply copy the linked database file to a backup directory automatically as the user exits the application. The messages display so I know it's finding the function but the DOS command box never opens, there's a pause to stop it closing. Can someone advise me please.