Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2007
    Posts
    40

    Unanswered: ADO connection table as source for combobox?

    Hi, I have an ADO Connection, and trying to set the source for a combobox to a table in the Connection. The problem is that obviously Access doesn't know where the table is when I give its name, and just looks in the current database. In DAO, I would have accomplished this by adding the external table to the TableDefs for the application, and then just treating it as if it was a table in the current database. So I would be able to just do

    Code:
    Combo0.RowSource = "SELECT ID, Name FROM ExtTable"
    and then it would work. But how do I do this in ADO? Is there any way to tell the combobox to execute the rowsource query on a separate ADO connection, rather than CurrentProject.Connection?

  2. #2
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    why not just link the table?

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Or refer to this if you want to do it in ADO:
    http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jun 2007
    Posts
    40
    Quote Originally Posted by rogue
    why not just link the table?
    It depends what you mean by "link the table". If you are referring to programmatically making the table part of the database then this is exactly what I am trying to do and I would welcome your advice on how to do this. However, if you are saying that I should use the "External Data/Link table" menu option, I'm afraid that this is out of the question as the file does not have a fixed path, so I have to manually create an ADO connection to it at runtime.

  5. #5
    Join Date
    Jun 2007
    Posts
    40
    I also tried to do this with ADOX. I did something along the lines of:

    Code:
    Dim TempCat As ADOX.Catalog
    Dim TempTable As ADOX.Table
    
    TempCat.ActiveConnection = ExtConn
    Set TempTable = TempCat.Tables("ExtTable")
    TempCat.ActiveConnection = CurrentProject.Connection
    TempCat.Tables.Append TempTable
    Why does this not work? It seems to work, but when I then base a combobox on the "imported" table, I get an error "-4034 Reserved Error Code. There is no description for this error." or something like that.

Posting Permissions

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