Results 1 to 3 of 3

Thread: SQL in Excel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    15
    I read the article about the memory leak - below is the code I use to read my Access table(s) - so I guess I am going to run into the memory problem. Can you suggest another method of connecting to Access or SQL for that matter.

    Is there a way I can monitor the amount of free memory - in the olden days the 'Free' command fullfilled that purpose - But I am not sure what replaces that command.

    Code:
    Public Sub FindFirstLastDates(strDBPath As String, DB_PW As String)
        Dim adoConn     As Object
        Dim rstRec      As Object
        Set adoConn = CreateObject("ADODB.Connection")
        Set rstRec = CreateObject("ADODB.Recordset")
        strTable = "SampleHeader"
        On Error Resume Next
        With adoConn
            Err.Clear
            .provider = "Microsoft.Jet.Oledb.4.0"
            .Properties("Jet OLEDB:Database Password") = DB_PW
            .Open "Data Source=" & strDBPath
            If Err.Number <> 0 Then
                On Error GoTo 0
                Exit Sub
            End If
        End With
        rstRec.Open "Select * from " & strTable & " ORDER BY SampleDateTime", adoConn, 3, 3
        rstRec.movefirst
        TxtStartDate.Text = Format(rstRec.fields("SampleDateTime"), "YYYY/MM/DD")
        rstRec.movelast
        TxtEndDate.Text = Format(rstRec.fields("SampleDateTime"), "YYYY/MM/DD")
        adoConn.Close
        On Error GoTo 0
    End Sub
    Last edited by Rasm; 01-24-2012 at 06:29 AM.
    xl2007 - Windows 7
    xl hates the 255 number

Similar Threads

  1. SQL output from Excel VBA macro
    By goldenbutter in forum Excel Help
    Replies: 3
    Last Post: 05-07-2013, 08:07 PM
  2. Upload Excel Data to SQL Table
    By littleiitin in forum Excel and VBA Tips and Tricks
    Replies: 3
    Last Post: 08-22-2012, 11:02 AM
  3. Replies: 2
    Last Post: 11-17-2011, 07:49 PM
  4. Execute SQL From Excel (VBA)
    By Mechanic in forum Excel and VBA Tips and Tricks
    Replies: 8
    Last Post: 10-02-2011, 04:30 PM
  5. Execute SQL From Excel (VBA)
    By Mechanic in forum Excel Help
    Replies: 0
    Last Post: 05-13-2011, 10:27 AM

Posting Permissions

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