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

    global dimension (2000 sr 1)

    I have this const to set the path of mdb

    Global Const gPROVADatabasePath = "E:MACROL0785-AUTCOGLIANDROPROVA.MDB"

    i substituite with succes in this part of code:

    Sub IMPORTA_TOTALE()
    ThisWorkbook.Activate
    Set ELENCO = Worksheets("L0785_TOTALE")
    CONT = FirstFree("L0785_TOTALE", "A", 6)
    Dim NomeDB As String
    Dim num As Integer

    NomeDB = "E:MACROL0785-AUTCOGLIANDROPROVA.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")
    Set OggettoRecordset = OggettoConnessione.Execute("SELECT * from TOTALE")

    but to sostituite the gloabl for this part of code i add a new global settin or is possible to use the same?
    Sub ADO_PAGATI()
    Dim num As Integer
    Sheets("L0785_PAGATI").Select
    Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long, n As Long
    Set cn = New ADODB.Connection
    ' **** Substitute the correct path ************
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=E:MACROL0785-AUTCOGLIANDROPROVA.MDB;"
    '**********************************************
    Set rs = New ADODB.Recordset
    rs.Open "PAGATI", cn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
    rs.Index = "SERVIZIO"
    r = 7 ' the start row in the worksheet
    Do While Len(Range("A" & r).Formula) > 0

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

    Re: global dimension (2000 sr 1)

    You should be able to use the constant in PAGATI too:

    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & gPROVADatabasePath & ";"

Posting Permissions

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