Access.2007.VBA.Bibl..

(John Hannent) #1
Private Sub cmdCustomBackupPath_Click()

On Error GoTo ErrorHandler

Dim strSelectedPath As String

Create a FileDialog object as a Folder Picker dialog box.

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Set txt = Me![txtBackupPath]

With fd
.title = _
“Browse for folder where backups should be stored”
.ButtonName = “Select”
.InitialView = msoFileDialogViewDetails
.InitialFileName = strBackupPath
If .Show = -1 Then
strSelectedPath = CStr(fd.SelectedItems.Item(1))
txt.Value = strSelectedPath
Set dbsCalling = CurrentDb
strPropName = “BackupPath”
Call SetProperty(strName:=strPropName, _
lngType:=dbText, varValue:=strSelectedPath)
Else
Debug.Print “User pressed Cancel”
End If
End With

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox “Error No: “ & err.Number _
& “; Description: “ & err.Description
Resume ErrorHandlerExit

End Sub

Private Sub cmdSave_Click()

On Error Resume Next

DoCmd.Close acForm, Me.Name

End Sub

Private Sub Form_Load()

Part III Adding More Functionality to Office

Free download pdf