Microsoft Access kept hanging on when .Show was called the second time in an application. I created a simple example showing it either hanging or killing the Access 2010 program running windows 7.

Clicking the first button and then the second button kills the Access program ("Access has stopped working..."). Clicking the first button and then the third button hangs, and you have to use the Task Manager to kill the application.

Changing the argument in btnBrowse1_Click to msoFileDialogPicker makes it all work. Various combinations of declaring f as FileDialog throughout produces various results, not all of them successful.

Option Compare Database

Private Sub btnBrowse1_Click()
Dim f As Object
Dim varfile As Variant

Set f = Application.FileDialog(msoFileDialogOpen) ' Argument was supposed to be msoFileDialogPicker
    f.initialfilename = "*.xls"
If f.Show Then
    If f.SelectedItems.Count > 0 Then
        For Each varfile In f.SelectedItems
            txtFilename = varfile
        Next
    End If
End If

End Sub

Private Sub btnBrowse2_Click()

Dim f As FileDialog
Dim varfile As Variant

Set f = Application.FileDialog(msoFileDialogFilePicker)
    f.initialfilename = "*.xls"
If f.Show Then
    If f.SelectedItems.Count > 0 Then
        For Each varfile In f.SelectedItems
            txtFilename = varfile
        Next
    End If
End If

End Sub

Private Sub btnBrowse3_Click()

Dim f As Object
Dim varfile As Variant

Set f = Application.FileDialog(msoFileDialogFilePicker)
    f.initialfilename = "*.xls"
If f.Show Then
    If f.SelectedItems.Count > 0 Then
        For Each varfile In f.SelectedItems
            txtFilename = varfile
        Next
    End If
End If

End Sub
Access 2010 Hangs
Kevin Koboldt's avatar

Kevin is the old graybeard of the group and we never let him forget it. He's a software developer by trade and a Ping Pong master in his spare time. He specializes in Android development but there's nothing he can't do.