Linda
Linda

Reputation: 55

FileDialog persists previous filters

I am making form in Access database I need to open file dialog window few times. I just don't get why after I change option value for a few times and open file dialog window it didn't change filters.

Public Sub Command17_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
    With fd
        .AllowMultiSelect = False
        If Option18.Value = True Then
         .Filters.Add "Access", "*.accdb", 1
        Else
        If Option20.Value = True Then
         .Filters.Add "Excel", "*.xlsx", 1
        End If
        End If
        .Show

 Text0.Value = fd.SelectedItems(1)
    End With
    Set fb = Nothing
End Sub

Upvotes: 4

Views: 395

Answers (1)

Kostas K.
Kostas K.

Reputation: 8518

You need to clear the filters.

With .Filters
    .Clear 
    .Add "Access", "*.accdb", 1
    '...
End with

Upvotes: 3

Related Questions