MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
I have the following data in a table tempdata: EmpNo EmpName DeptNo 1 Roger 1 2 Mike 1 3 Wayne 2 4 Whitney 3 5 Anne 3 Main.frm has following code Private Sub Command1_Click() Dim oRS As ADODB.Recordset Dim oCn As ADODB.Connection Dim mDataBaseName As String Dim oEmp As Class1 Dim cEmp As Collection Dim iLoop As Integer Set oRS = New ADODB.Recordset Set oCn = New ADODB.Connection Set cEmp = New Collection mDataBaseName = App.Path & "\test.mdb" oCn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mDataBaseName & ";Jet OLEDB:Database Password=" & PWD & ";") oRS.CursorLocation = adUseClient oRS.Open "select * from tempdata", oCn Do While Not oRS.EOF Set oEmp = New Class1 With oEmp .EmpNo = oRS.Fields("EmpNo").Value .EmpName = oRS.Fields("EmpName").Value .DeptNo = oRS.Fields("DeptNo").Value End With cEmp.Add oEmp Loop For iLoop = 1 To cEmp.Count With cEmp.Item(iLoop) Debug.Print .EmpNo, .EmpName, .DeptNo End With Next iLoop If oRS.State Then oRS.Close If oCn.State Then oCn.Close Set cEmp = Nothing Set oRS = Nothing Set oCn = Nothing End Sub class1.cls has following code: Private mEmpNo As Integer Private mEmpName As String Private mDeptNo As Integer Public Property Let EmpNo(vEmpNo As Integer) mEmpNo = vEmpNo End Property Public Property Get EmpNo() As Integer EmpNo = mEmpNo End Property Public Property Let EmpName(vEmpName As String) mEmpName = vEmpName End Property Public Property Get EmpName() As String EmpName = mEmpName End Property Public Property Let DeptNo(vDeptNo As Integer) mDeptNo = vDeptNo End Property Public Property Let DeptNo(vDeptNo As Integer) DeptNo = mDeptNo End Property
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.