Home arrow Visual Basic arrow Page 3 - Implementing An ADO Data Control With VB6
VISUAL BASIC

Implementing An ADO Data Control With VB6


The ADO data control can save Visual Basic developers hours of time. In this article Susan shows us exactly how to go about implementing an ADO control.

Author Info:
By: Susan Harkins
Rating: 4 stars4 stars4 stars4 stars4 stars / 147
June 15, 2002
TABLE OF CONTENTS:
  1. · Implementing An ADO Data Control With VB6
  2. · What is a data control?
  3. · Adding the remaining controls
  4. · Conclusion

print this article
SEARCH DEVARTICLES

Implementing An ADO Data Control With VB6 - Adding the remaining controls
(Page 3 of 4 )

Add the appropriate label and text box controls until your form resembles the one shown in Figure A. Set each text box control's DataSource property to adoData (or the name of your ADO data control) to bind the text box to the data control.

Now you need to bind each control to a field. To do so, select a field from the text box control's DataField property. It's also a good idea to name each control. The table below lists the names we chose for our controls:


Quick Tip: You can save time when creating several controls of the same type by creating one control and setting all the shared properties. Then, use the Copy and Paste commands to create the total number of controls you'll need.

When VB asks if you’re creating a control array, answer "No". Once you have all the controls you need, simply select them individually and enter the unique properties -- such as the Name property. Now, let's finish our form by adding the last control -- a command button. Name that button cmdExit.

If you like, add the caption property E&xit. At this point, double-click the command button to open the form's module and add the procedure shown below. Close the window to return to your form.

Private
Sub
cmdExitCommand_Click()
Unload
frmDataControl
End
Sub


Running The Project
At this point you're ready to run the project, so click F5. The form (in Figure A) displays the first record in the bound table (from Nwind.mdb). Click the navigational controls to move from one record to another. Remember that if you change the data in a record and then move to another record, VB will save the changes.

Try to add a new record by first clicking the Last button and then clicking the Next button. The first click will display the last record in the bound table. The second click will display a blank record (if you've set the data control's properties accordingly). If your form doesn't display a blank record then return to Design View, select the ADO data control and change it's EOFAction property to 2 - adDoAddNew.



Once you view a blank (new) record, you may encounter a problem if you try to return to a previous record. If your form includes any required fields, VB won't let you leave the new record until you enter something in the required fields. This behavior includes primary key fields and any required fields you may not have displayed on your form. You can however, exit your form by clicking the Exit command button.
blog comments powered by Disqus
VISUAL BASIC ARTICLES

- Developing an XML Web Service Using Visual S...
- Creating an HTML File List with VB
- Fun with Email: VB6, CDO, MAPI, and a Remote...
- Extranet/Intranet Dictionary Cracker in VB
- Finding Default App Icons With Visual Basic
- Registry Fever With Visual Basic
- Implementing An ADO Data Control With VB6
- Printing With Visual Basic
- MSMQ Part 1/2: Architecture and Simple Imple...
- Magnifying The Desktop With Visual Basic
- Sending Email With MAPI Components in Visual...
- Two Person Chat With The Winsock Control And...
- A Real-Time ActiveX News Control
- Accessing the Windows API in Visual Basic

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials