[AccessD] using ADO to populate combos - was RE: Error 3048 Cannotopen any more databases

Martin W Reid mwp.reid at qub.ac.uk
Wed Mar 5 08:47:16 CST 2008


Out of the archives

if g_oConnection = OpenConenction then
     Dim oRes As ADODB.Recordset
     Dim sListText As String
     Set oRes = New ADODB.Recordset
     Me.cboMyList.ColumnCount = 2
     Me.cboMyList.BoundColumn = 1
     Me.cboMyList.ColumnHeads = False
     Me.cboMyList.ColumnWidths = "0;1"
     Me.cboMyList.RowSourceType = "Value List"
     Me.cboMyList.DefaultValue = 0
     oRes.Open "select * from tbMyTable order by label", g_oConnection,
adOpenDynamic, adLockOptimistic
     sListText = "0;'<Anything>';"
     While oRes.EOF = False
           sListText = sListText & oRes("ID").Value & ";" &
oRes("Label").Value & ";"
           oRes.MoveNext
       Wend
       oRes.Close
       Me.cboMyList.RowSource = sListText
       Set oRes = Nothing
       CloseConnection
   end if


Martin WP Reid
Information Services
Queen's University
Riddel Hall
185 Stranmillis Road
Belfast
BT9 5EE
Tel : 02890974465
Email : mwp.reid at qub.ac.uk
________________________________________
From: accessd-bounces at databaseadvisors.com [accessd-bounces at databaseadvisors.com] On Behalf Of Susan Harkins [ssharkins at gmail.com]
Sent: 05 March 2008 14:35
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] using ADO to populate combos - was RE: Error 3048        Cannotopen any more databases

John, I think the control has a property named Recordset -- look for

Set ctl.Recordset = rst

I think you have to do this programmatically -- don't think there's a manual
choice. I might be wrong about this, I know you can do this with forms.

Susan H.


> Is it in fact possible to make the rowsource an ADO recordset or am I
> delusional?  If possible, how is it done?  Example code would be nice.

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list