Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATA Control. Data Control caption Get first Get previous Get next Get last.

Similar presentations


Presentation on theme: "DATA Control. Data Control caption Get first Get previous Get next Get last."— Presentation transcript:

1 DATA Control

2 Data Control caption Get first Get previous Get next Get last

3 A DATA control on a form points to one table in a database. A DATA control accesses data, it does not display it We need to BIND label controls and text controls to the data control in order to display the data

4 To look at one field in one table in one database: 1. Put one data control and one label control on the form. 2. Specify database by setting data control’s “database name”. 3. Specify database table by setting data control’s “record source”. 4. Bind the label control to the data control by setting the label control’s “data source”. 5 Select the database field to display by setting the label control’s “data field”. 6 Run the project and browse the database.

5 DATABASE NAME - name of database RECORD SOURCE - table name RECORD SET - all records in table Recordset.MoveFirst - go to top of table Recordset.MoveLast - go to bottom of table Recordset.MoveNext - go to next record Recordset.MovePrevious - go to previous record Recordset.BOF - beginning of table Recordset.EOF - end of table

6

7 Private Sub cmdFirst_Click ( ) datFriends.Recordset.MoveFirst End Sub Private Sub cmdLast_Click ( ) datFriends.Recordset.MoveLast End Sub Private Sub cmdExit_Click ( ) End End Sub

8 Private Sub cmdNext_Click ( ) datFriends.Recordset.MoveNext If datFriends.Recordset.EOF = True then Msgbox “Already at end of table”, vbInformation datFriends.Recordset.Movelast End If End Sub n.b. vbInformation = ! symbol

9 Private Sub cmdPrev_Click ( ) datFriends.Recordset.MovePrevious If datFriends.Recordset.BOF = True then Msgbox “Already at beginning of table”, vbInformation datFriends.Recordset.Movefirst End If End Sub n.b. vbInformation = ! symbol

10 Private Sub cmdDelete_Click ( ) Const WARNDELETE = “Are you sure you want to delete the record?” Dim BoxType As Integer Dim Response As Integer BoxType = vbYesNo + vbCritical + vbDefaultButton2

11 Response = MsgBox (WARNDELETE, Boxtype) If Response = vbYes then datFriends.Recordset.Delete If datFriends.Recordset.EOF = True then datFriends.Recordset.MoveLast End If End Sub

12 Private Sub cmdFind_Click ( ) Dim Target As String Target = txtName.Text Target = “Name = “ & Target datFriends.Recordset.FindFirst Target If datFriends.Recordset.NoMatch then MsgBox “No records found” End If End Sub


Download ppt "DATA Control. Data Control caption Get first Get previous Get next Get last."

Similar presentations


Ads by Google