We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 62,012 times

Contents

Related Categories

DAO 3.6 Library - A Worked Example

LouisRose

A Worked Example

So now you have a wonderful library that helps you to add, edit and delete records. You've written a Default Database module too that links the library with your Access database. But how does it all tie together?

Below, I'll show you the code that will add two records to the people table, edit their fields and then delete one of the records. See if you can figure out how to do the same to the animals table. For now, you can just stick this in your Form_Load procedure. It may be useful to use the debugging tools to step through the code and see exactly what is going on.

Dim strPath as String
Dim intNewRecord As Integer
Dim intReturn As Integer
Dim intRecordToDelete As Integer

strPath = "C:\My Documents\Test.mdb"
LoadDatabase strPath

intNewRecord = AddNewRecord(rstPeople)

intReturn = ChangeField(rstPeople, intNewRecord, "FirstName", "Louis")
intReturn = ChangeField(rstPeople, intNewRecord, "LastName", "Rose")
intRecordToDelete = intNewRecord

intNewRecord = AddNewRecord(rstPeople)
intReturn = ChangeField(rstPeople, intNewRecord, "FirstName", "Laura")
intReturn = ChangeField(rstPeople, intNewRecord, "LastName", "Hickson")

intReturn = DeleteRecord(rstPeople, intRecordToDelete)


If you check your database in Access now, you'll see that VB has added one person to the People database and the values of the fields (from left to right) will be: 2, Laura, Hickson

In fact, we added me to the database too, but then promptly deleted me. (Humph!)

I hope this library will give you some help and make using DAO 3.6 a doddle.

Happying DAOing!

Louis Rose

Comments

  • Re: [2527] DAO 3.6 Library

    Posted by BarbStewart on 12 Jun 2008

    I am working in VB6 with an Access db and would like to delete records from a join table. Can you help me? I have a table of Products, and table of Materials and a table to join the...

  • Re: [2527] DAO 3.6 Library

    Posted by faisalwadood on 20 Feb 2007

    hi sir!


    i hav read your article fully,i also read many articles on vb databases i understand it well yet i hav have a problem if you kindly help me.


    i want to develop a vb applicati...

  • Re: [2527] DAO 3.6 Library

    Posted by Nishantha on 13 Jul 2006


    Dear Sir,


    <...

  • Bad Type

    Posted by StevoMc on 14 Jul 2004

    This tutorial has been really good for helping me understand how to use access databases, which is really cool, but unfortunately I'm having a problem.

    When writing the code for moddefaultdatabase...

  • Posted by bruwmac on 22 Jun 2004

    What? Where the heck did that come from?

    :eek: :confused: :D