Setting references in code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Setting references in code

  1. #1
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557

    Setting references in code

    How do I set references in the database I just created AND set the order of the reference?

    I found this:
    Dim ref as Reference

    Set ref = References.AddFromFile("c:\Program Files\Common Files\Microsoft Shared\DAO\dao360")

    How do I tell it in what order and in which database?

    I'm such a pain-in-the-***!

    L
    A balanced diet is a cookie in each hand.

  2. #2
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    I'm trying to set a reference in another database and the order of that reference.
    A balanced diet is a cookie in each hand.

  3. #3
    Join Date
    Dec 2003
    Posts
    2,750
    References is a Collection of the Application object. In this case you would probably have to create another instance of Access, open the database for which you want add the Reference(s) in this new instance (using OpenCurrentDatabase), save the database changes after adding the references, close the database and then terminate this instance of Access.

    Not sure how you would change the priority of the references other than to add them in the order you want them to appear.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  4. #4
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    Thanks, Paul. I'll give it a try and let you know what I come up with.

    L
    A balanced diet is a cookie in each hand.

  5. #5
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    P.S. There's something about posting in this forum that jump-starts my brain. I usually figure things out before anyone has a chance to reply, but THIS one is one that I could NOT figure out!
    A balanced diet is a cookie in each hand.

  6. #6
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    WOW! IT ONLY TOOK ME ALL DAY!

    Okie dokie Paul, just in case you ever need to know the answer to this one, here it is:

    You "set the priority" by removing the ones that are the "offending" ones and then add them back in in the order you want. The REMOVING was the hard part! I tried EVERY DAYUM THANG!

    Here's what I ended up with. I'm too tired to check for efficiency.

    Code:
    
        Set NewDb = New Access.Application
        NewDb.OpenCurrentDatabase (LFilename)
        For i = 1 To NewDb.References.Count
            Set ref = NewDb.References(i)
            If ref.Name = "ADODB" Then
                NewDb.References.Remove ref
                Exit For
            End If
        Next i
    
        Set ref = NewDb.References.AddFromFile("c:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll")
        Set ref = NewDb.References.AddFromFile("c:\Program Files\Common Files\System\ADO\msado21.tlb")
    You know, if I would just learn ADO, I wouldn't have had to do this! I think I need a little work on collections, too!!

    HAVE A NICE WEEKEND, EVERYBODY!

    L&K,
    Laurel
    A balanced diet is a cookie in each hand.

Similar Threads

  1. Control Arrays in VB.NET
    By Gary Nelson in forum .NET
    Replies: 277
    Last Post: 10-01-2003, 01:00 AM
  2. Speaking of strings...
    By Harlow in forum .NET
    Replies: 246
    Last Post: 10-26-2002, 01:30 AM
  3. Replies: 2
    Last Post: 07-22-2002, 12:19 PM
  4. Replies: 90
    Last Post: 04-17-2001, 01:45 AM
  5. Replies: 0
    Last Post: 08-11-2000, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center