locked
Reference problem when using two different MsAccess versions RRS feed

  • Question

  • Dear world,

    When working on different computers with different versions of MSAccess I run into a problem with references. The name/path Reference in 2003 MSAccess version is different than the one used in 2010. 

    I am looking for a solution in such a way, so I can use both versions of MSAccess for the same database. Now I get an error message saying something like "Cann't find ( or missing) reference" after I used the 2010 version,  when I switch back in using the 2003 version of MS Access.

    Thanks in advance,

    JC

    Wednesday, September 30, 2015 12:50 PM

Answers

  • Hi. Which references are you having problems with? If you're using any libraries outside of the default, you might consider converting your code to use late binding to avoid reference problems. Just a thought...
    Wednesday, September 30, 2015 2:56 PM
  • Hi. Let's say for example that you have the following code:

    Dim xlApp As Excel.Application
    Dim xlWbk As Excel.Workbook
    Dim xlSht As Excel.Sheet
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlWbk = xlApp.Open("c:\MyFile.xlsx")
    Set xlSht = xlWbk.Sheets("Sheet1")
    

    To convert that to late binding, you will modify it as follows:

    Dim xlApp As Object
    Dim xlWbk As Object
    Dim xlSht As Object
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlWbk = xlApp.Open("c:\MyFile.xlsx")
    Set xlSht = xlWbk.Sheets("Sheet1")

    Please note that the above code is just an example. I didn't test it to make sure I'm using the correct Excel properties. The point being is that you would replace all variable declarations to a generic object rather than Excel objects and if you use any constants, you will have to replace them with their numerical value.

    For example, if you create an email using Outlook automation, you would normally use the following line:

    Set MyEmail = MyOutlook.CreateItem(olMailItem)

    That would become like this using late binding:

    Set MyEmail = MyOutlook.CreateItem(0)

    Hope that helps...

    • Marked as answer by JCaesar32 Thursday, October 15, 2015 8:39 AM
    Thursday, October 8, 2015 3:21 PM

All replies

  • Hi. Which references are you having problems with? If you're using any libraries outside of the default, you might consider converting your code to use late binding to avoid reference problems. Just a thought...
    Wednesday, September 30, 2015 2:56 PM
  • I have a problem with the Excel and Word libraries/references in MSAccess version 2010 versus 2003.

    ...Concerning your remark: How do I convert my code into late binding?

    Thx in advance.

    Thursday, October 8, 2015 1:45 PM
  • Hi. Let's say for example that you have the following code:

    Dim xlApp As Excel.Application
    Dim xlWbk As Excel.Workbook
    Dim xlSht As Excel.Sheet
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlWbk = xlApp.Open("c:\MyFile.xlsx")
    Set xlSht = xlWbk.Sheets("Sheet1")
    

    To convert that to late binding, you will modify it as follows:

    Dim xlApp As Object
    Dim xlWbk As Object
    Dim xlSht As Object
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlWbk = xlApp.Open("c:\MyFile.xlsx")
    Set xlSht = xlWbk.Sheets("Sheet1")

    Please note that the above code is just an example. I didn't test it to make sure I'm using the correct Excel properties. The point being is that you would replace all variable declarations to a generic object rather than Excel objects and if you use any constants, you will have to replace them with their numerical value.

    For example, if you create an email using Outlook automation, you would normally use the following line:

    Set MyEmail = MyOutlook.CreateItem(olMailItem)

    That would become like this using late binding:

    Set MyEmail = MyOutlook.CreateItem(0)

    Hope that helps...

    • Marked as answer by JCaesar32 Thursday, October 15, 2015 8:39 AM
    Thursday, October 8, 2015 3:21 PM
  • Thank you it worked without the reference  to the Object library of Excel (version 11.0 and on the other machine version 14.0).

    However I still have to work on the rest of the code, like saving the workbook with particular name etc.  This is not done automatically (the old code worked fine in naming the workbook and placing it in a special folder.)

     

    Thursday, October 15, 2015 8:44 AM
  • Hi. Glad to hear you got it to work. Using late binding should never have anything to do with how your old code works. It just eliminates the dependencies to specific external libraries. So, if your old code can save the file with a specific name, then your new code should also be able to do the same. If it doesn't, maybe you can post it here so we can take a look. Cheers!
    Thursday, October 15, 2015 3:26 PM