Article ID: 113956
Article Last Modified on 3/2/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
Sub Command1_Click ()
Dim ds As Dynaset
Dim db As database
Set db = OpenDatabase("BIBLIO.MDB")
' Enter the following two lines as one, single line:
Set ds =
db.CreateDynaset("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
Sub Command2_Click ()
Dim ds As Dynaset
Dim db As database
Set db = OpenDatabase("BIBLIO.MDB")
' Enter the following two lines as one, single line:
Set ds = db.CreateDynaset("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
Sub Command3_Click ()
Dim ds As Dynaset
Dim db As database
Set db = OpenDatabase("BIBLIO.MDB")
' Enter the following two lines as one, single line:
Set ds = db.CreateDynaset("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
Keywords: kbhowto KB113956