Consulting

Results 1 to 8 of 8

Thread: Solved: MISSING: Microsoft ActiveX Data Objects Record 2.8 Library

  1. #1
    VBAX Newbie
    Joined
    Jul 2005
    Posts
    4
    Location

    Solved: MISSING: Microsoft ActiveX Data Objects Record 2.8 Library

    As a newbie that has inherited the further customization of an application I have been experiencing an unusual problem.

    I have an EXCEL VBA application (Excel 2002) that sends data to a SQLSERVER which works most of the time.

    I have gone into References and selected "Microsoft ActiveX Data Objects Recordset 2.7 Library"

    Every now and again I recieve my Excel application back from a user and when I try to run the application and load the SQLSERVER I get an error. When I check the References I find "MISSING: Microsoft ActiveX Data Objects Recordset 2.8 Library"

    To resolve the problem I uncheck the MISSING:... option, close the References drop down, re-open the references and check what I had originally checked. "Microsoft ActiveX Data Objects Recordset 2.7 Library"

    Is there a way of putting something in the code to prevent this from happening of does every one of the users have to be running the same version of Excel?

    I know that this is somewhat long winded but I have spent considerable time looking for solutions in the many different forums and through textbooks.

    The connection code looks like this:

    [vba]'==================== DATABASE CONNECTION =============
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim strSQL As String
    Dim lngRecsAff As Long
    ' now lets try to make the database connection here now
    Set cn = New ADODB.Connection
    cn.Open dbConnString
    Set rs = New ADODB.Recordset
    cn.Execute sqlInsStr, lngRecsAff, adExecuteNoRecords

    Dim strCustomerReferenceNumber As String

    strCustomerReferenceNumber = Replace(Sheet1.Cells(4, 5), "'", "''")

    ' now lets get the primary key
    strSQL = "SELECT customerID FROM ipOppCustomer where customerReferenceNumber = '" & strCustomerReferenceNumber & "'"

    rs.Open strSQL, cn
    Sheet1.Cells(222, 2) = rs("customerID")
    rs.Close
    ' now close the connection
    cn.Close
    Set cn = Nothing
    '==================== END DATABASE CONNECTION ======[/vba]

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hi there,

    Nope, don't have to be running the same Excel version, but you have to code for that possibility. A later version automatically upgrades the references on you, which gives you the issue going back.

    Check these out, as they may be helpful:
    Add a VBA Reference Library via code
    Remove Missing VBA Library References via code

    Cheers!
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Trying to set references in code opens an extra can of worms, with additional security levels, and more opportunities for problems.

    The real solution to this problem is to use a multi-file approach. The code goes into an add-in; each user installs the add-in, and if any updated references are present, they update on that user's computer without screwing up anyone else's. All the data is stored in another workbook; when you receive a workbook from another user, there's no code and no references in the workbook to cause problems.
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hey Jon,

    That's a different approach than I've used in the past, but I'd agree that it would be the preferable one. I does take a little more groundwork and organization to set up, though, but ultimately should avoid this problem entirely.

    Darnit all though... I was quite proud of those entries!
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Ken -

    I spent weeks with one client trying to incorporate a similar system into his existing solution, which was based on a single workbook that contained all the code. His program used Solver, which is among the least friendly add-ins to interact with. The references crashed half the time. We ended up using Application.Run to interact with Solver.

    If I could have talked him into separating the data part from the program part, and distribute an add-in and a template, we could have made solver work much better. A two-part system is much more flexible, and much easier to update. How do you update just the code in a workbook that has code, data, and formatting all integrally merged? It's next to impossible. In a multi-part system, you change one part, and the other parts remain intact.

    In fact, a three part system is even better: program, data, and presentation. The whole XML thing is about keeping the data separate from the presentation.
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by JonPeltier
    In fact, a three part system is even better: program, data, and presentation. The whole XML thing is about keeping the data separate from the presentation.
    Before that, client-server also had that as an objective. Then the three level paradigm, client (presentation), application (business logic), and server (data management) is the right way to go IMO. You can always hybrid with valid, considered (and documented) reasons.

  7. #7
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Great feedback, guys, and I do appreciate it. It's also an approach that's endorsed by Bullen, Bovey & Green in their Professional Application Development book. That one is a bit of a slow read for me now, but I do see the value here.

    Thanks guys!
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  8. #8
    VBAX Newbie
    Joined
    Jul 2005
    Posts
    4
    Location
    I still had problems with setting the references but realized after some research that the solution was, if I was to keep the application intact, was to remove the reference altogether and late bind.

    Being from 'Old School' I would have prefereed to separate, application, code and data but given my timelines that wasn't an option this time.

    Thank you for all of your input.

Posting Permissions

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