Dim d As database
Dim ds As dynaset
Dim dbopen As Integer
Dim dsopen As Integer

Sub Command1_Click ()
On Error GoTo posterr
If Not dbopen Then
   Set d = OpenDatabase("")
   dbopen = True
End If
If Not dsopen Then
   Set ds = d.CreateDynaset("Presenters")
Else
'
' Assume we want to start from the top
'
   ds.Close
   Set ds = d.CreateDynaset("presenters")
End If
If ds.EOF Then          'Any data in the table?
   MsgBox "Table 'Presenters' is empty - run VBITS02!"
   ds.Close
   d.Close
   dsopen = False
   dbopen = False
   Exit Sub
End If
'
'Everything went well, let's put the data into the text controls
'
'I'll show different (equivalent) syntax's for gettting
'the field's value
'
Lastname.Text = ds.Fields(0).Value      'Full syntax w/ordinal
firstname.Text = ds.Fields("firstname") 'Value is default propert - accessed by name (could have used (1))
company.Text = ds(2)                    'Fields is default collection (by ordinal)
topics.Text = ds("topic")               'By name
Exit Sub

posterr:
If dbopen Then
   d.Close
   dbopen = False
   MsgBox "Couldn't open table 'Presenters'."
Else
   MsgBox "OpenDatabase failed"
End If
Exit Sub
End Sub

Sub Command2_Click ()
If ds.EOF Then
   MsgBox "End of Data!"
   Exit Sub
End If
ds.MoveNext
If ds.EOF Then
   MsgBox "End of Data!"
Else
'
'I'll show different (equivalent) syntax's for gettting
'the field's value
'
   Lastname.Text = ds.Fields("lastname").Value 'Full syntax w/name
   firstname.Text = ds.Fields(1)               'Value is default propert - accessed by ordinal (could have used ("Lastname"))
   company.Text = ds("Company")                'Fields is default collection (by name)
   topics.Text = ds(3)                         'By ordinal
End If
End Sub

Sub Command3_Click ()
If dsopen Then
   ds.Close
End If
If dbopen Then
   d.Close
End If
End
End Sub

Sub Form_Load ()
dbopen = False
dsopen = False
End Sub

