Article ID: 147724
Article Last Modified on 4/1/2005
Control Name Property New Value
--------------------------------------------------------------------
Label1 Caption Selecting the first 10 titles from the
Titles table according to title field.
Label2 Caption Selecting the first 5 titles from the
Titles table according to date published.
Label3 Caption Selecting the first 7 years of percent
published from the Titles table according
to the year published field.
Command1 Caption First 10 Title names.
Command2 Caption First 5 titles dates published.
Command3 Caption First 7 years percent published.
Private Sub Command1_Click ()
Dim ds As Recordset
Dim db As database
Set db = Workspaces(0).OpenDatabase("BIBLIO.MDB")
Set ds = _
db.OpenRecordset("select top 5 title from titles order by title")
Do Until ds.EOF
list1.AddItem "" & ds("title")
ds.MoveNext
Loop
ds.Close
db.Close
End Sub
Private Sub Command2_Click ()
Dim ds As Recordset
Dim db As database
Set db = Workspaces(0).OpenDatabase("BIBLIO.MDB")
Set ds = db.OpenRecordset("select top 5 [year published], _
title from titles order by [year published]")
Do Until ds.EOF
list2.AddItem "" & ds("title")
ds.MoveNext
Loop
ds.Close
db.Close
End Sub
Private Sub Command3_Click ()
Dim ds As Recordset
Dim db As database
Set db = Workspaces(0).OpenDatabase("BIBLIO.MDB")
Set ds = db.OpenRecordset("select top 7 Percent [year published], _
title from titles order by [year published]")
Do Until ds.EOF
list3.AddItem "" & ds("title")
ds.MoveNext
Loop
ds.Close
db.Close
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbdse kbDSupport kbVBp
Keywords: kbhowto KB147724