+ Reply to Thread
Results 1 to 2 of 2

Display the result in excelsheet from Access table

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Display the result in excelsheet from Access table

    Hi guys

    I want to display the result of a query from Access table to Excel spreadsheet. I have written the following code to fetch the data from the Access table but have no idea how to display that in excel sheet. Can anyone please help me out in this.
    Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim r As Long
           Set cn = New ADODB.Connection
       cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source=C:\Documents and Settings\Amanpreet Kaur\Desktop\resc.mdb;"
          Set rs = New ADODB.Recordset
         rs.Open "tblmain", cn, adOpenKeyset, adLockOptimistic, adCmdTable
        rs.Find "Department = ' " & ComboBox1.Value & " '
    Thanks in advance!!

    Aman

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388

    Re: Display the result in excelsheet from Access table

    Range.CopyFromRecordset could be useful.

    Quote from Excel Help:
    Copies the contents of an ADO or DAO Recordset object onto a worksheet, beginning at the upper-left corner of the specified range.
    Worksheets(1).Range("A2").CopyFromRecordset rs

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1