+ Reply to Thread
Results 1 to 12 of 12

Working with adodb recordsets (virtual and table based)

  1. #1
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Working with adodb recordsets (virtual and table based)

    I have defined a virtual ADODB recordset that captures what I need in the sheet.
    "SELECT Job, DateCurr, DateERP FROM RST1 R"

    I need to query the associated dates in our ERP system

    The table in the ERP, connected thourgh SQL
    "SELECT Job, DateERP FROM dbo.WipMaster W"

    Of course I could do a 3rd query combining the first two recordsets. My question is a syntax one; can I avoid doing it and create directly something that will be;
    R.Job, R.DateCurr. W.DateERP ?

  2. #2
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Re: Working with adodb recordsets (virtual and table based)

    I tried ;

    Please Login or Register  to view this content.
    I guess that I can't do that as it sends the line to the SQL server (?) I get an error 13 type mismatch on rstADO rstADO is my 'virtual' recordset that I populated and checked the content with debug.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with adodb recordsets (virtual and table based)

    Hi,

    You should be able to nest one select inside the other like this
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Re: Working with adodb recordsets (virtual and table based)

    I get an SQL error; Invalid Object Name 'RST1'

    (In my 2nd post, RST1 has become rstADO)

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with adodb recordsets (virtual and table based)

    I missed that you were querying two different systems. What provider do you use to access the ERP system?

  6. #6
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Re: Working with adodb recordsets (virtual and table based)

    The first RST1 is a new recordset I defined with Fields.Append; it is populated and checked.

    The second is connected to our SQL server. If I got what you asked for, it is a classic
    cnn.ConnectionString = "DRIVER=SQL Server;SERVER=XXX;Trusted_Connection=No;DATABASE=MyDb;UID=sa;Password=MyPwd"
    that works no problem.

    Basically, what I want to achieve is to compare the job date (DateCurr) in the Excel sheet to the one in our ERP (DateERP).

    I built the first recordset because this isn't a range. The DateCurr field is populated with a function.
    Last edited by Saintor; 03-05-2018 at 09:24 AM.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Working with adodb recordsets (virtual and table based)

    I suspect that you'd be better off generating an in clause on job id for SQL server from your recordset and then comparing against that

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with adodb recordsets (virtual and table based)

    I can't test this but would think that using OPENROWSET might work
    Please Login or Register  to view this content.
    It's not a great idea to do this on an open workbook due to memory leaks but might be OK for a single query

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Working with adodb recordsets (virtual and table based)

    I'll go out on a limb and say it won't as it's unlikely that MSSQL has access to the C: drive of a random user, or indeed access to anywhere much!

  10. #10
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Re: Working with adodb recordsets (virtual and table based)

    I have an hunch that I am not doing it right.

    I have two recordsets that I want to combine on job=job, so it would be a query maybe?

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with adodb recordsets (virtual and table based)

    You can't simply combine two separate recordsets. You need to create one recordset from the original data, or create two data sources in the same location (Excel or SQL Server) that you can then join in one query.

  12. #12
    Registered User
    Join Date
    08-22-2016
    Location
    MTL, CA
    MS-Off Ver
    2013
    Posts
    60

    Re: Working with adodb recordsets (virtual and table based)

    I see.

    Sorry if it sounds a bit compliated, byt possibly the solution back to my original idea in this THREAD. Using an array instead of the first recordset.

    Thanks to the gentleman there, I was able to get a recorset based on an array, but I couldn't get to the point of simply having Job [from the array], DateCurr [from the array], DateERP [from the recorset]. I guess that I would need a 3-columns array and the 3rd coplumn column would be updated from the recordset.

+ 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. working with excel windows and virtual desktops
    By k1dr0ck in forum Excel General
    Replies: 0
    Last Post: 07-11-2017, 03:33 AM
  2. What's the best way to combine SQL and ACE ADODB recordsets?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2015, 04:39 PM
  3. Virtual Pivot table
    By millzerr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2011, 06:24 AM
  4. ADODB Recordsets
    By cosmarchy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-24-2010, 04:53 PM
  5. [SOLVED] Excel Pivot Table Virtual Memory
    By Rodrigo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2006, 05:10 PM
  6. Creating a virtual table in VBA Excel
    By Jean-Jérôme Doucet via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2005, 04:05 PM
  7. Creating a virtual table in VBA Excel
    By Werner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2005, 03:11 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