Visualizzazione dei risultati da 1 a 10 su 13

Visualizzazione discussione

  1. #5
    Utente di HTML.it L'avatar di Bugu
    Registrato dal
    Nov 2007
    Messaggi
    871
    L'importazione la faccio cosi:

    codice:
    Public Function impTable()
    Dim f As Object
        Dim strFile As String
        Dim strFolder As String
        Dim varItem As Variant
    
    
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        If f.Show Then
            For Each varItem In f.SelectedItems
                strFile = Dir(varItem)
                strFolder = Left(varItem, Len(varItem) - Len(strFile))
                
    DoCmd.DeleteObject acTable, "CompareTable1"
    ' Import data from Excel using a static range
    DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel12, "CompareTable1", strFolder & strFile, True, "A1:Z1"
    checkTable
    Next
    End If
        Set f = Nothing
    End Function
    
    
    Public Function checkTable()
    Dim db As DAO.Database
    Dim tbl1 As DAO.TableDef
    Dim tbl2 As DAO.TableDef
    Dim intLoop As Integer
    Dim strMessage As String
      
      Set db = CurrentDb
      Set tbl1 = db.TableDefs("Table1")
      Set tbl2 = db.TableDefs("CompareTable1")
        
      If tbl1.Fields.Count = tbl2.Fields.Count Then
      MsgBox "ok"
       
      Else
        strMessage = tbl1.Name & " has " & tbl1.Fields.Count & " fields, while " & _
          tbl2.Name & " has " & tbl2.Fields.Count & " fields." & vbCrLf
      End If
      
      
      If tbl1.Fields.Count > tbl2.Fields.Count Then
      action1
      End If
      
      If tbl1.Fields.Count < tbl2.Fields.Count Then
      action2
      End If
      
      If tbl1.Fields.Count = tbl2.Fields.Count Then
      action3
          End If
      
      
      Set tbl2 = Nothing
      Set tbl1 = Nothing
      Set db = Nothing
    End Function
    In questo modo importo una tabella xls esterna e faccio la comparazione dei suoi campi con la mia Table1 (che è quella che contiene i campi giusti).
    Quello che devo ottenere è una funzione che mi dica se la tabella xls esterna è identica alla mia Table1 come struttura (nome e numero di campi).
    A seconda del risultato eseguo un'azione.
    Credo sia un metodo piuttosto macchinoso e mi obbliga ad importare la tabella, mentre io vorrei qualcosa di piu snello che mi consenta di controllare i campi da fuori senza importare.
    E' possibile?
    Ultima modifica di Bugu; 18-02-2019 a 10:21
    Linux User
    ---------
    Solo due cose sono infinite: l'universo e la stupidità umana, e non sono tanto sicuro della prima.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.