David McAfee
DMcAfee at haascnc.com
Thu Aug 14 15:55:34 CDT 2003
The value list will work but has a few caveats. 1. Any semi-colons or commas in your data will mess up your columns (make sure you strip them out prior to filling list box) 2. There is a smaller size limit, so if you are expecting to have a lot of data in your combo box (hidden columns) then you will be limited. David -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Martin Reid Sent: Thursday, August 14, 2003 7:47 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Setting A2K combo box rowsource using ADO - SOLVED Try Rowsource instead of Recordset This is an example I got somewhere 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