Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IMPORT 2 TABLE ... (2000 sr 1)

    connection to .mdb

    This macro take a data from an .mdb with 1 table and put it in to FOGLIO1, my problem is to take in automatic in the same time the other data of 2 table ...


    for example i have a .mdb DBDELIVERY.mdb it contain 2 table TABLE1 and TABLE2...

    Insert in the sheet FOGLIO1 the data of TABLE1 and in the sheet FOGLIO2 the data of TABLE2

    The start cell is the same for all table strat from A10


    code:

    -------------------------------------------------------------------------------- Option Explicit
    Sub EstrazioneDati1()

    ' --- Esatto nome del Database completo del percorso
    ' --- nel caso il Database specificato non esista nel percorso, la macro genera un'errore
    ' --- verificare quindi l'esistenza del Database

    Dim NomeDB As String
    NomeDB = "srv04f9494rmtbaspTEMPDBDELIVERY.MDB"

    Dim StringaDiConnessione
    StringaDiConnessione = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & NomeDB & ";'"

    Dim OggettoConnessione As Object, OggettoRecordset As Object
    Set OggettoConnessione = CreateObject("ADODB.Connection")
    OggettoConnessione.Open StringaDiConnessione
    Set OggettoRecordset = CreateObject("ADODB.Recordset")

    ' --- in questa istruzione SQL

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IMPORT 2 TABLE ... (2000 sr 1)

    Hello Salvatore,

    Does Table2 have the same structure as Table1, i.e. does it have the same field names?

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IMPORT 2 TABLE ... (2000 sr 1)

    Tks for your help! And for the speedy ....
    Table1 have 13 column and table2 7
    And all have a different name of column

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IMPORT 2 TABLE ... (2000 sr 1)

    In that case you will have to write a separate procedure to import the data from Table2. You can insert an instruction to activate the correct worksheet (foglio) for each procedure: in EstrazioneDati1, insert a line

    Sheets("Foglio1").Select

    above

    Range("A4:N65536").ClearContents

    Create a similar procedure EstrazioneDati2, and use

    Sheets("Foglio2").Select

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IMPORT 2 TABLE ... (2000 sr 1)

    ok! if i have understand i make two separate macro?

    macro1 to import table1 sheet foglio1
    an
    macro2 to import table2 sheet foglio2

    ... or not?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IMPORT 2 TABLE ... (2000 sr 1)

    Yes, that is correct, you should make two separate macros. You can then make a third macro that calls the separate macros:

    Sub EstrazioneTuttiDati()
    EstrazioneDati1
    EstrazioneDati2
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •