Library tutorials & articles

ADO Data Control

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, if you change the data in a record and then move to another record, VB will save the change.

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--as shown in Figure B. If your form doesn’t display a blank record, return to Design View, select the ADO data control and change it’s EOFAction property to 2 - adDoAddNew.

Figure B

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.

Comments

  1. 26 Sep 2005 at 09:11
    Well I think the code should look like:
    Private Sub Form_Load()
    dcPekerja.Visible = False
    dcPekerja.ConnectionString = App.Path & "\db1.mdb"
    dcPekerja.RecordSource = "Select * From Table1;"
    End Sub

    All you have to add is a tiny little "\" and there you have it. I suppose that you already figured it out by now but if not hope it helps. Also make sure that the database is in the same directory as the ".exe" or ".vbp"

    Have fun coding!
  2. 23 Sep 2005 at 20:00
    Hi there... I went though your code and fond one mistake...

    Private Sub Form_Load()
    dcPekerja.Visible = False
    dcPekerja.ConnectionString = App.Path + "db1.mdb"
    dcPekerja.RecordSource = "Select * from Table1;"
    End Sub

    You Should Have

    Private Sub Form_Load()
    dcPekerja.Visible = False
    dcPekerja.ConnectionString = "\\db1.mdb"
    dcPekerja.RecordSource = "Select * From Table1;"
    End Sub
  3. 14 Sep 2004 at 01:23

    Or not

  4. 14 Sep 2004 at 01:21

    Well i supose you do have the database in the same directory with the application on the other computer

  5. 23 Apr 2004 at 23:34

    i'm using adodc to connect to access
    but i'm having problem when i use the application on other pc...
    it say that it cant found the database file...


    i use this coding... but still the error is there...


    Private Sub Form_Load()
    dcPekerja.Visible = False
    dcPekerja.ConnectionString = App.Path + "db1.mdb"
    dcPekerja.RecordSource = "Select * from Table1;"
    End Sub


    i also try this code...but nothing happens...
    Private Sub Form_Load()
    dcPekerja.Visible = False
    dcPekerja.ConnectionString = App.Path & "db1.mdb"
    dcPekerja.RecordSource = "Select * from Table1;"
    End Sub


    dcPekerja => adodc

  6. 27 Feb 2003 at 16:20

    Gave me insight, thanks

  7. 03 Aug 2002 at 15:38

    IMHO - The Data Control's sole usefullnes is when you literally want to scroll the data, one record at a time.javascript:smilie('')
    frown


    I find it MUCH easier to roll my own ADO RS control that will search for the resocrd(s) I need...javascript:smilie('')
    stick out tongue javascript:smilie('')
    wink


    This control should ONLY be used by total DB Newbies!!! (IMHO)javascript:smilie('')
    eek!

  8. 01 Jan 1999 at 00:00

    This thread is for discussions of ADO Data Control.

Leave a comment

Sign in or Join us (it's free).

Susan Harkins
AddThis

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

We'd love to hear what you think! Submit ideas or give us feedback