2017-05-30 77 views
2

我使Access數據庫中的窗體我需要打開文件對話窗口幾次。我只是不明白,爲什麼我改變選項值幾次後,打開文件對話窗口,它沒有改變過濾器。FileDialog堅持以前的過濾器

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 

回答

3

您需要清除篩選條件。

With .Filters 
    .Clear 
    .Add "Access", "*.accdb", 1 
    '... 
End with 
相關問題