M
markawmaw
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
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