Question : CommonDialog control in Access 2007  -- problem

I have some code related to dialogs that we have used for quite awhile that all of a sudden recently stopped working and I can not figure out why.  The area in the code where it breaks is provided bellow.  Also, I noticed if I try to export a form to another database that has a CommonDialog (class: MSComDlg.CommonDialog.1) I get a error message that says, "There was a error loading and Active X control on one of your forms or reports". "Make sure all of the controls that you are using are properly registered.  

I provided the code bellow with a comment where it breaks.  Of couse it looks like the problem is with the control itself and not the code but it might provide some sort of clue.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Example of what happens in the code:
 
Private Sub Command33_Click()
  Dim strDedUpdateFileName As String
      strDedUpdateFileName = szFileOpenDLG("Text (*.txt)|*.txt|All Files (*.*)|*.*", "*.Txt", Me)
 
End Sub
 
CALLS A MODULE WITH THE CODE
 
Public Function szFileOpenDLG(ByVal strFilter As String, _
                              ByVal strDefaultExt As String, _
                              ByRef frmCurForm As Form) As String
    
  frmCurForm.OpnDlg.FileName = strDefaultExt
  frmCurForm.OpnDlg.strDefaultExt = strDefaultExt 'IT BREAKS HERE WITH THE MESSAGE OBJECT DOES SUPPORT THIS PROPERTY OR METHOD
  frmCurForm.OpnDlg.CancelError = False
  frmCurForm.OpnDlg.strFilter = strFilter
  frmCurForm.OpnDlg.Flags = &H8& Or &H800& Or &H1000&
  frmCurForm.OpnDlg.ShowOpen
 
  szFileOpenDLG = frmCurForm.OpnDlg.FileName
  
End Function

Answer : CommonDialog control in Access 2007  -- problem

Not really strange, since you're using a control that's not intended to be used in Access ... IOW, there may be an update that's been applied that "breaks" this control in such a way that Access cannot use it. Most developers have long avoided the CommonDialog control and instead use API calls to show the File Open dialog ...

That said, there is no way this line of code has EVER worked correctly:

frmCurForm.OpnDlg.strDefaultExt = strDefaultExt 'IT BREAKS HERE WITH THE MESSAGE OBJECT DOES SUPPORT THIS PROPERTY OR METHOD

Simply put, there is no property named "strDefaultExt" for the Common Dialog control ...

I mistyped my earlier comment ... this should have been:

frmCurForm.OpnDlg.DefaultExt = strDefaultExt 'IT BREAKS HERE WITH THE MESSAGE OBJECT DOES SUPPORT THIS PROPERTY OR METHOD

Here's a reference to this control:
http://msdn.microsoft.com/en-us/library/aa238597(VS.60).aspx
Random Solutions  
 
programming4us programming4us