VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

Database Application



A database application can be created using data control in Visual Basic. The data control support some methods that are useful in manipulating the database, for example, to move the pointer to a certain location. The following are some of the commands:

data_navigator.RecordSet.MoveFirst            ' Move to the first record

data_navigator.RecordSet.MoveLast;         ' Move to the last record

data_navigator.RecordSet.MoveNext        ' Move to the next record

data_navigator.RecordSet.Previous             ' Move to the first record

data_navigator.RecordSet.AddNew               ' Adds a new record

data_navigator.RecordSet.Update              'Saves new record

data_navigator.RecordSet.Delete               ' Deletes a current record

*note: data_navigator is the name of data control

In the following example, you need to insert four commands and label them as First Record, Next Record, Previous Record and Last Record as well as  name them as cmdFirst, cmdNext, cmdPrevious and cmdLast.You also need to insert the data control.They will be used to navigator around the database without using the data control.

The Interface

The Code

Private Sub cmdFirst_Click()
dtaBooks.Recordset.MoveFirst
End Sub


Private Sub cmdNext_Click()
dtaBooks.Recordset.MoveNext
End Sub


Private Sub cmdPrevious_Click()
dtaBooks.Recordset.MovePrevious
End Sub

Private Sub cmdLast_Click()
dtaBooks.Recordset.MoveLast
End Sub


 


Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy