Rob,
Are you using one Access database to work inside of another Access database?
Are you using ADO to hit a SQL server?
I am trying to understand why you would be using ODBCDirectWorkspace...
The following is a simple DAO version of what I think you are trying to do.
____________________________________________________________
Private Sub LoadComboBox_DAO()
Dim daoDbs As DAO.Database
Dim daoQdf As DAO.QueryDef
Dim strSql As String
Set daoDbs = CodeDb
strSql = "SELECT EmployeeID, [FirstName] & SPACE(1) & [LastName] As NAME
FROM dbo_tblEmployees;"
Set daoQdf = daoDbs.CreateQueryDef("MyNewQry")
daoQdf.sql = strSql
strSql = ""
daoQdf.Close
daoDbs.Close
Set daoQdf = Nothing
Set daoDbs = Nothing
Me.cboMyBox.RowSource = "Select * from MyNewQry Order By Name;"
Me.Requery
Me.Repaint
Me.cboMyBox.SetFocus
End Sub
___________________________________________________________
However if you are going to be using this query again to populate the combo
box
you may not want to destroy and recreate it over and over. It may be better
to
just change the SQL of the query rather than create it repeatedly. And on
another thought do you realy need the query at all? What purpose does
creating this query serve? You can simply feed the results of your SQL
directly into the object.
________________________________________________________________
Private Sub LoadComboBox_SQL()
Me.cboMyBox.RowSource = "SELECT EmployeeID, [FirstName] & SPACE(1) &
[LastName] FROM dbo_tblEmployees Order By FirstName;"
Me.Requery
Me.Repaint
Me.cboMyBox.SetFocus
End Sub
________________________________________________________________
--
~ SPARKER ~
Rob M said:
If I create a ODBCDirect Workspace object, and then a Connection object, and
then a QueryDefinition, I am unable to use the query that has been created as
the RowSource for a ComboBox. The ComboBox doesn't recognize that the query
exists. Am I doing something wrong, or is this just not possible? Thanks
for helping.