User-defined type not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AllusiveKitten
    New Member
    • Feb 2007
    • 43

    User-defined type not defined

    Hi All

    I am hoping someone can assist.... I have imported all of the table, queries, forms & modules from one database into a new database I have created. I am now getting a 'User-defined type not defined' error on the following coding:

    Code:
    Dim dlg As CommonDialog
    I have checked that all of the references are the same and the only one that I can see where there maybe a problem is Command Controls... In the old data base the reference is "Microsoft Common Dialog Control 6.0 (SP3) and the new database has "Microsoft Windows Commond Controls 6.0 (SP6). Neither Database has the alternate reference in their list and I believe both have been created in Access 2003.

    I really hope there is a simplet explanation.

    Thank you

    AK
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by AllusiveKitten
    Hi All

    I am hoping someone can assist.... I have imported all of the table, queries, forms & modules from one database into a new database I have created. I am now getting a 'User-defined type not defined' error on the following coding:

    Code:
    Dim dlg As CommonDialog
    I have checked that all of the references are the same and the only one that I can see where there maybe a problem is Command Controls... In the old data base the reference is "Microsoft Common Dialog Control 6.0 (SP3) and the new database has "Microsoft Windows Commond Controls 6.0 (SP6). Neither Database has the alternate reference in their list and I believe both have been created in Access 2003.

    I really hope there is a simplet explanation.

    Thank you

    AK
    The Microsoft Common Dialog Control is an ActiveX Control that has a visual interface so you do not set a Reference to it. To place this Control on your Form, assuming it is Registered:
    1. View
    2. Toolbox
    3. Bottom of Toolbox where the small tools Icon and ... are, click on this button.
    4. Draw the Common Dialog Box on your Form as you would any built-in Control, then Reference its as you would a normal Control.

    Comment

    • AllusiveKitten
      New Member
      • Feb 2007
      • 43

      #3
      Originally posted by ADezii
      The Microsoft Common Dialog Control is an ActiveX Control that has a visual interface so you do not set a Reference to it. To place this Control on your Form, assuming it is Registered:
      1. View
      2. Toolbox
      3. Bottom of Toolbox where the small tools Icon and ... are, click on this button.
      4. Draw the Common Dialog Box on your Form as you would any built-in Control, then Reference its as you would a normal Control.
      Hi ADezzi

      Now I feel like a real fool... the CommonControl has been created and it all works in the old database, here is the full coding that uses the control.

      Code:
      Dim dlg As CommonDialog
      Dim strRootFolder As String
      Dim strFile As String
       
          'check that data has been entered
          If DCount("Name", "Data") = 0 Then
              MsgBox "Please populate data table"
              DoCmd.OpenTable "Data"
              Exit Sub
          End If
          
          DoCmd.SetWarnings False
          
          Me.lblStatus.Caption = "Creating data"
          DoCmd.OpenQuery "DeleteDepartments"
          DoCmd.OpenQuery "DeleteDepartmentsAndDocs"
          DoCmd.OpenQuery "DeleteOldPathNames"
      
          DoCmd.OpenQuery "AppendDepartments"
          DoCmd.OpenQuery "AppendDepartmentsAndDocs"
      
          Set dlg = Me.CommonDialog3.Object
          
          With dlg
              .Filename = "9999SD190.xls"
              .DialogTitle = "Open Standard 190 - Procedure Index"
              .InitDir = "P:\AusMS"
              .ShowOpen
               strRootFolder = .Filename
          End With
      I dont understand why it all works in one data base and as soon as you import it to another, it stops working at the very first line of coding.

      Cheers
      AK

      Comment

      • AllusiveKitten
        New Member
        • Feb 2007
        • 43

        #4
        Where I have been saying CommonControl, I mean CommonDialog... .. no wonder I am confusing my self..!!

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          It's always a good idea to show the entire sub when dealing with code! Sometimes things that you, as the original poster, don't consider germaine could, in fact be so! Access has a bad habit of not always hi-lighting the actual offending line, but rather hi-lighting one line off from the bad code. Could you post the missing code?

          Linq ;0)>

          Comment

          • AllusiveKitten
            New Member
            • Feb 2007
            • 43

            #6
            Originally posted by missinglinq
            It's always a good idea to show the entire sub when dealing with code! Sometimes things that you, as the original poster, don't consider germaine could, in fact be so! Access has a bad habit of not always hi-lighting the actual offending line, but rather hi-lighting one line off from the bad code. Could you post the missing code?

            Linq ;0)>
            Code:
            Private Sub cmdRun_Click()
            Dim dlg As CommonDialog
            Dim strRootFolder As String
            Dim strFile As String
             
                'check that data has been entered
                If DCount("Name", "Data") = 0 Then
                    MsgBox "Please populate data table"
                    DoCmd.OpenTable "Data"
                    Exit Sub
                End If
                
                DoCmd.SetWarnings False
                
                Me.lblStatus.Caption = "Creating data"
                DoCmd.OpenQuery "DeleteDepartments"
                DoCmd.OpenQuery "DeleteDepartmentsAndDocs"
                DoCmd.OpenQuery "DeleteOldPathNames"
            
                DoCmd.OpenQuery "AppendDepartments"
                DoCmd.OpenQuery "AppendDepartmentsAndDocs"
            
                Set dlg = Me.CommonDialog3.Object
                
                With dlg
                    .Filename = "9999SD190.xls"
                    .DialogTitle = "Open Standard 190 - Procedure Index"
                    .InitDir = "P:\AusMS"
                    .ShowOpen
                     strRootFolder = .Filename
                End With
                
                ' get root folder
                If strRootFolder <> "" Then
                    strRootFolder = Replace(strRootFolder, "9999SD190.xls", "")
                Else
                    Exit Sub
                End If
                
                Me.lblStatus.Caption = "Sorting document to folders"
                DoEvents
                
                With An1
                   .Visible = True
                   .AutoPlay = True
                   .Open AviFile
                   DoEvents
                End With
                Call SortDocsToDirectories(strRootFolder)
                
                An1.Close
                
                ' Delete all docs from root except "9999SD190.xls"
                strFile = Dir(strRootFolder & "*.*")
                
                Me.lblStatus.Caption = "Deleting Root Level Documents"
                Do While strFile <> ""
                    
                    If strFile <> "9999SD190.xls" Then
                        Kill strRootFolder & strFile
                    End If
                    
                    strFile = Dir
                Loop
                
                Me.lblStatus.Caption = "Updating Paths"
                DoCmd.OpenQuery "UpdatePaths"
                DoEvents
                
                Me.lblStatus.Caption = "Updating Hyperlinks"
                DoEvents
                Call ExtractExcelHyperlinks2(strRootFolder & "9999SD190.xls")
                
                DoCmd.OpenQuery "UpdateOldPathNames"
                DoCmd.OpenQuery "UpdateDataTableWithOldPaths"
                
                Call FixExcelHyperlinks(strRootFolder & "9999SD190.xls")
                
                ' delete "9999SD190.xls" files
                Kill strRootFolder & "9999SD190.xls"
                Kill strRootFolder & "Quality\Standard\" & "9999SD190.xls"
                 
                FileCopy strRootFolder & "9999SD190_Relinked.xls", strRootFolder & "9999SD190.xls"
                FileCopy strRootFolder & "9999SD190_Relinked.xls", strRootFolder & "Quality\Standard\" & "9999SD190.xls"
                
                Kill strRootFolder & "9999SD190_Relinked.xls"
                
                Me.lblStatus.Caption = "Done"
                DoEvents
                
            End Sub

            Hi missinglinq

            I hope this helps, because I am absolutely stumped

            Thx
            AK

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by AllusiveKitten
              Hi ADezzi

              Now I feel like a real fool... the CommonControl has been created and it all works in the old database, here is the full coding that uses the control.

              Code:
              Dim dlg As CommonDialog
              Dim strRootFolder As String
              Dim strFile As String
               
                  'check that data has been entered
                  If DCount("Name", "Data") = 0 Then
                      MsgBox "Please populate data table"
                      DoCmd.OpenTable "Data"
                      Exit Sub
                  End If
                  
                  DoCmd.SetWarnings False
                  
                  Me.lblStatus.Caption = "Creating data"
                  DoCmd.OpenQuery "DeleteDepartments"
                  DoCmd.OpenQuery "DeleteDepartmentsAndDocs"
                  DoCmd.OpenQuery "DeleteOldPathNames"
              
                  DoCmd.OpenQuery "AppendDepartments"
                  DoCmd.OpenQuery "AppendDepartmentsAndDocs"
              
                  Set dlg = Me.CommonDialog3.Object
                  
                  With dlg
                      .Filename = "9999SD190.xls"
                      .DialogTitle = "Open Standard 190 - Procedure Index"
                      .InitDir = "P:\AusMS"
                      .ShowOpen
                       strRootFolder = .Filename
                  End With
              I dont understand why it all works in one data base and as soon as you import it to another, it stops working at the very first line of coding.

              Cheers
              AK
              Linq is correct, we simply need to look at the overall picture here. The information that you have provided is simply not enough, I'm not sure if you are attempting to access the Windows Common Dialog Boxes, a Class, etc.

              Comment

              • AllusiveKitten
                New Member
                • Feb 2007
                • 43

                #8
                Originally posted by AllusiveKitten
                Code:
                Private Sub cmdRun_Click()
                Dim dlg As CommonDialog
                Dim strRootFolder As String
                Dim strFile As String
                 
                    'check that data has been entered
                    If DCount("Name", "Data") = 0 Then
                        MsgBox "Please populate data table"
                        DoCmd.OpenTable "Data"
                        Exit Sub
                    End If
                    
                    DoCmd.SetWarnings False
                    
                    Me.lblStatus.Caption = "Creating data"
                    DoCmd.OpenQuery "DeleteDepartments"
                    DoCmd.OpenQuery "DeleteDepartmentsAndDocs"
                    DoCmd.OpenQuery "DeleteOldPathNames"
                
                    DoCmd.OpenQuery "AppendDepartments"
                    DoCmd.OpenQuery "AppendDepartmentsAndDocs"
                
                    Set dlg = Me.CommonDialog3.Object
                    
                    With dlg
                        .Filename = "9999SD190.xls"
                        .DialogTitle = "Open Standard 190 - Procedure Index"
                        .InitDir = "P:\AusMS"
                        .ShowOpen
                         strRootFolder = .Filename
                    End With
                    
                    ' get root folder
                    If strRootFolder <> "" Then
                        strRootFolder = Replace(strRootFolder, "9999SD190.xls", "")
                    Else
                        Exit Sub
                    End If
                    
                    Me.lblStatus.Caption = "Sorting document to folders"
                    DoEvents
                    
                    With An1
                       .Visible = True
                       .AutoPlay = True
                       .Open AviFile
                       DoEvents
                    End With
                    Call SortDocsToDirectories(strRootFolder)
                    
                    An1.Close
                    
                    ' Delete all docs from root except "9999SD190.xls"
                    strFile = Dir(strRootFolder & "*.*")
                    
                    Me.lblStatus.Caption = "Deleting Root Level Documents"
                    Do While strFile <> ""
                        
                        If strFile <> "9999SD190.xls" Then
                            Kill strRootFolder & strFile
                        End If
                        
                        strFile = Dir
                    Loop
                    
                    Me.lblStatus.Caption = "Updating Paths"
                    DoCmd.OpenQuery "UpdatePaths"
                    DoEvents
                    
                    Me.lblStatus.Caption = "Updating Hyperlinks"
                    DoEvents
                    Call ExtractExcelHyperlinks2(strRootFolder & "9999SD190.xls")
                    
                    DoCmd.OpenQuery "UpdateOldPathNames"
                    DoCmd.OpenQuery "UpdateDataTableWithOldPaths"
                    
                    Call FixExcelHyperlinks(strRootFolder & "9999SD190.xls")
                    
                    ' delete "9999SD190.xls" files
                    Kill strRootFolder & "9999SD190.xls"
                    Kill strRootFolder & "Quality\Standard\" & "9999SD190.xls"
                     
                    FileCopy strRootFolder & "9999SD190_Relinked.xls", strRootFolder & "9999SD190.xls"
                    FileCopy strRootFolder & "9999SD190_Relinked.xls", strRootFolder & "Quality\Standard\" & "9999SD190.xls"
                    
                    Kill strRootFolder & "9999SD190_Relinked.xls"
                    
                    Me.lblStatus.Caption = "Done"
                    DoEvents
                    
                End Sub

                AK
                Hi All

                I am still having trouble with this coding error, I have recreated the database and all is fine until I convert the database to 2003-2003 File Format so as that I can MBE the database. It is after I convert the database that I am getting the User-defined error.

                Has anyone come across the same problem that could give me a solution to my problems??

                Thank you kindly

                AK

                Comment

                Working...