Lesson 24: Advanced Database Techniques in VB6
Learn to create custom navigation buttons, manipulate records, and build professional database interfaces
Key Takeaway
Visual Basic provides powerful database manipulation methods that allow you to create custom navigation interfaces and add, update, and delete records programmatically.
Welcome to Lesson 24 of our Visual Basic 6 Tutorial! In this lesson, you'll learn advanced database techniques building on the foundation from Lesson 23. We'll create custom navigation buttons, implement record manipulation functionality, and design a professional database interface without relying on the visible Data Control.
24.1 Custom Navigation Buttons
In Lesson 23, you used the Data Control's built-in navigation buttons. Now, you'll create your own custom navigation buttons for a more professional interface. The key methods for record navigation are:
MoveFirst
Moves to the first record in the recordset
data_navigator.Recordset.MoveFirst
MovePrevious
Moves to the previous record in the recordset
data_navigator.Recordset.MovePrevious
MoveNext
Moves to the next record in the recordset
data_navigator.Recordset.MoveNext
MoveLast
Moves to the last record in the recordset
data_navigator.Recordset.MoveLast
24.1.1 Implementation Steps
To implement custom navigation buttons:
1Hide the Data Control
Set the Data Control's Visible property to False
2Add Command Buttons
Create four buttons: First, Previous, Next, Last
3Write Event Handlers
Implement the navigation methods in button click events
Private Sub cmdFirst_Click() ' Move to the first record data_navigator.Recordset.MoveFirst End Sub Private Sub cmdPrevious_Click() ' Move to the previous record data_navigator.Recordset.MovePrevious End Sub Private Sub cmdNext_Click() ' Move to the next record data_navigator.Recordset.MoveNext End Sub Private Sub cmdLast_Click() ' Move to the last record data_navigator.Recordset.MoveLast End Sub

24.2 Record Manipulation
Beyond navigation, you can manipulate records with these essential methods:
AddNew
Creates a new blank record ready for data entry
data_navigator.Recordset.AddNew
Update
Saves changes made to the current record
data_navigator.Recordset.Update
Delete
Deletes the current record from the database
data_navigator.Recordset.Delete
24.2.1 Implementation Steps
To implement record manipulation:
1Add Manipulation Buttons
Create buttons: Add New, Save, Delete
2Write Event Handlers
Implement record manipulation methods
3Add Confirmation
Implement confirmation dialogs for critical operations
Private Sub cmdAdd_Click() ' Create a new record data_navigator.Recordset.AddNew End Sub Private Sub cmdSave_Click() ' Save the current record data_navigator.Recordset.Update MsgBox "Record saved successfully!", vbInformation End Sub Private Sub cmdDelete_Click() ' Confirm deletion Dim response As Integer response = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion) If response = vbYes Then data_navigator.Recordset.Delete data_navigator.Recordset.MoveNext If data_navigator.Recordset.EOF Then data_navigator.Recordset.MoveLast End If End If End Sub
Advanced Database Browser
Try browsing and manipulating customer records using the custom buttons:
24.3 Professional Interface Design
With custom navigation and record manipulation buttons, you can design a more professional and user-friendly interface:
Custom Layout
Design your own button layout for optimal usability
Visual Design
Apply consistent styling and color schemes
Validation
Add data validation before saving records
Lesson Summary
In this lesson, you've learned advanced database techniques in VB6:
Custom Navigation
Creating your own navigation buttons with MoveFirst, MovePrevious, MoveNext, MoveLast
Record Manipulation
Adding, saving, and deleting records with AddNew, Update, and Delete
Professional UI
Designing custom interfaces without the visible Data Control
Confirmation Dialogs
Implementing user confirmation for critical operations
Important Note
When implementing custom navigation, always check for BOF (Beginning of File) and EOF (End of File) conditions to prevent errors when moving beyond record boundaries.
Practice Exercises
Enhance your database application with these exercises:
Exercise 1: Boundary Checking
Implement BOF and EOF checks in your navigation buttons to prevent errors at record boundaries.
Exercise 2: Data Validation
Add validation to ensure required fields are filled before saving a record.
Exercise 3: Undo Functionality
Implement an "Undo" button to cancel changes to the current record.
Exercise 4: Record Counter
Display the current record position and total records (e.g., "Record 3 of 25").
Exercise 5: Search Function
Add a search feature to find records by customer name or ID.
Next Lesson
Continue your VB6 journey with Lesson 25: Using ADO Control.
Related Resources

Visual Basic 6 Made Easy
The ultimate beginner-friendly guide for mastering Windows-based application development using Visual Basic 6. Used as a textbook by universities worldwide.
What You'll Learn:
- Comprehensive coverage of VB6 coding techniques
- Database application development
- Practical examples and projects
- Debugging and error handling
- Advanced database integration
- Professional UI development

Visual Basic 2022 Made Easy
The ultimate guide to VB.NET programming in Visual Studio 2022. Master modern VB development with this comprehensive resource.
What You'll Learn:
- Modern VB.NET coding techniques
- Visual Studio 2022 features
- Database programming with ADO.NET
- Advanced UI development
- Entity Framework integration
- Deployment strategies