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
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?
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.
I also tried to do this with ADOX. I did something along the lines of:
Dim TempCat As ADOX.Catalog
Dim TempTable As ADOX.Table
TempCat.ActiveConnection = ExtConn
Set TempTable = TempCat.Tables("ExtTable")
TempCat.ActiveConnection = CurrentProject.Connection
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.