Copy Database to Selected Folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Following code does not work. Any suggestions would be appreciated.

Dim strFolderName As String

strFolderName = BrowseFolder("What Folder do you want to select?")

FileSystem.FileCopy "C:\TestDB.mdb", strFolderName & "TestDB_Backup.mdb"
 
Do you have code for the UDF BrowseFolder() in your database?

The FileCopy statement works fine.
 
you cannot copy a database while other people are using it.
you cannot move a database while other people are usign it.

this is one of the central short-comings in Access MDB format.. it is
ridiculous to manage

Lose the training wheels and use Access Data Projects


-Aaron
 
The following code is in my DB:

Option Compare Database

'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With

dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)

If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
'*********** Code End *****************
 
You are right. It works fine. I had a typo in my statement.

Thanks for the reply(s)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top