+ Reply to Thread
Results 1 to 3 of 3

Workbook_SheetChange / Open Recordset #vba #sql #excel

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    19

    Workbook_SheetChange / Open Recordset #vba #sql #excel

    Hello all,

    I'm new to vba so after any advice please. What I would like to do is when J29 is changed which is a validation list then run a query based on the selection and paste the recordset into J30

    So far I have

    Private sub Workbook_SheetChange

    Dim Cn as Adodb.connection
    Dim rst as new Adodb.recordset

    Set Cn = new Adodb.connection
    Cn.open "this is obviously link to my database"

    Rst.open "select site from qy_6_6_1 where service centre = '" & range("j29") & "'", cn
    This workbook.worksheets("network summary").range("j30").copyfromrecordset rst
    Rst. Close
    Cn. Close

    End sub

    Look forward to you pointing me in the right direcrion

    Cheers
    Last edited by cooksteve09; 01-26-2017 at 04:13 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Workbook_SheetChange / Open Recordset

    Please use code tags and upload a sample workbook, thank you

  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Workbook_SheetChange / Open Recordset #vba #sql #excel

    I can't attach it as it's sensitive to my work place, the code is working kind but the worksheet_change I need to tell it just network summary sheet not all sheets, any ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Data Type Mismatch Error on Open Recordset
    By masouder in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2016, 11:56 AM
  2. Open another recordset within current recordset vba
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2015, 04:32 AM
  3. run a sql statement in for loop and open a recordset
    By rfjkzxc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2013, 11:18 PM
  4. Open the recordset in access and use table name in dmax statement
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-10-2010, 06:56 AM
  5. Recordset Query : how to open and retrieve DB
    By superkid in forum Access Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2009, 05:31 PM
  6. [SOLVED] Open recordset using ODBC
    By Mr B in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2006, 02:15 PM
  7. [SOLVED] How to open Access recordset via Query in Excel VBA???
    By Hexman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2006, 03:15 PM

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