Re: Bindind a listbox to a recordset using DAO in Access 2000 VBA
From: Jezebel (dwarves_at_heaven.com.kr)
Date: 07/25/04
- Previous message: markawmaw: "Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- In reply to: markawmaw: "Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Next in thread: markawmaw: "Re: Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Reply: markawmaw: "Re: Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 25 Jul 2004 18:02:30 +1000
Unless things have changed since W2000, you can bind a listbox to a
recordset at all. RowSource works only in Excel, and only to bind the list
to a range of cells.
You'll need to populate the list by hand:
Do until rs.EOF
Forms("form1").Controls!List3.AddItem rs(1)
:
"markawmaw" <work@markaw.com> wrote in message
news:96cbe965.0407242346.36089294@posting.google.com...
> Hi All,
>
> I can't seem to get this to work. I know the recordset is being
> created and I know that is has the right number of records in it, but
> the Listbox doesn't appear to bind itself; I end with a blank list
> box.
>
> The form (form1) has a listbox on it (list3) and a command buton
> (command2)
>
> Option Compare Database
>
> Private Sub Command2_Click()
>
> On Error GoTo exitSub
>
> Dim wks As DAO.workspace
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
>
> Set wks = CreateWorkspace("", "admin", "", dbUseJet)
> Set db = wks.OpenDatabase("c:\tmp\db1.mdb")
> Set rs = db.OpenRecordset("SELECT cmp_s_name FROM tblCompany",
> dbOpenSnapshot)
>
>
> Forms("form1").Controls!List3.ColumnCount = rs.Fields.Count
> Forms("form1").Controls!List3.RowSourceType = "Table/Query"
> Forms("form1").Controls!List3.RowSource = "SELECT * FROM
> tblCompany"
> Forms("form1").Controls!List3.Requery
>
> MsgBox rs.Fields.Count
>
> Exit Sub
>
> exitSub:
> Debug.Print Err.Number
> Debug.Print Err.Description
> Set rs = Nothing
> Set db = Nothing
> Set wks = Nothing
>
> End Sub
- Previous message: markawmaw: "Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- In reply to: markawmaw: "Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Next in thread: markawmaw: "Re: Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Reply: markawmaw: "Re: Bindind a listbox to a recordset using DAO in Access 2000 VBA"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|