Visual Basic
  Home arrow Visual Basic arrow Page 3 - Implementing An ADO Data Control With VB6
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

Implementing An ADO Data Control With VB6
By: Susan Harkins
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 123
    2002-06-15

    Table of Contents:
  • Implementing An ADO Data Control With VB6
  • What is a data control?
  • Adding the remaining controls
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    More Visual Basic Articles
    More By Susan Harkins


       · I really enjoy the tutorial on ADO in visual basic,but now am having a challenge on...
       · I am working in VB 6 and I registered the ADO data control but when I want to add it...
     

    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







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek