Extras Options

The fdlgExtrasOptions form module contains the code behind the Extras Options dialog, where you can set up your preferences for the backup save folder, or the prefixes to exclude when listing fields:

Option Compare Database Option Explicit

Private dbsCalling As DAO.Database Private fd As Office.FileDialog Private intChoice As Integer Private prps As DAO.Properties Private prp As DAO.Property Private strBackupChoice As Integer Private strBackupPath As String Private strCallingDb As String Private strPropName As String Private strTable As String Private tdfs As DAO.TableDefs Private tdf As DAO.TableDef Private txt As Access.TextBox Private varPropValue As Variant

Private Sub cmdCancel_Click() On Error Resume Next

DoCmd.Close acForm, Me.Name, End Sub acSaveNo

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

"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:

& "; 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()

On Error Resume Next

DoCmd.RunCommand acCmdSizeToFitForm On Error GoTo ErrorHandler intChoice = Nz(Me![BackupChoice], 2) Select Case intChoice Case 1

Me![cmdCustomBackupPath].Enabled = False Case 2

Me![cmdCustomBackupPath].Enabled = False Case 3

Me![cmdCustomBackupPath].Enabled = True

End Select

ErrorHandlerExit: Exit Sub

ErrorHandler:

& "; Description: " & err.Description Resume ErrorHandlerExit

End Sub

Private Sub fraBackupOptions_AfterUpdate()

On Error GoTo ErrorHandler intChoice = Nz(Me![fraBackupOptions].Value, 2) strBackupChoice = CStr(intChoice) strBackupPath = Nz(Me![BackupPath])

Select Case intChoice

Case 1

Me![cmdCustomBackupPath].Enabled = False Case 2

Me![cmdCustomBackupPath].Enabled = False Case 3

Me![cmdCustomBackupPath].Enabled = True End Select

Save the users choice to a database property in the calling database.

Set dbsCalling = CurrentDb strPropName = "BackupChoice"

Call SetProperty(strName:=strPropName, _

lngType:=dbText, varValue:=strBackupChoice)

ErrorHandlerExit: Exit Sub

ErrorHandler:

& "; Description: " & err.Description Resume ErrorHandlerExit

End Sub

0 0

Post a comment