More Database Questions


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: More Database Questions

Hybrid View

  1. #1
    Matt Wyant Guest

    More Database Questions


    It's me again.

    I have created a DAO 3.6 Access database program, and I need to know a couple
    things.

    I need to be able to add and delete a record. I would like the new record
    to be appended to the end of the database. And when I delete, I would like
    it to be the current record.

    Any help would be appreciated, but please keep in mind that I am a very new
    programmer and the more detailed the explanation the more helpgul it is.

    Thank you.

    Matt Wyant
    MDWyant@SRPnet.com
    Http://www.public.asu.edu/~Mwyant

  2. #2
    Arthur Wood Guest

    Re: More Database Questions


    in order to add a new record to the databse, you will create a recordset object
    and open it with an SQL Select statement which will creatre all of the fields
    to be populated. YOu will the use the AddNew method of the record set, populate
    the fields with the new data values, and the save the record with the Update
    method of the recordset. This will in fact insert that new record at the
    "end of the table".

    When you delete a record, you create a recordset object,
    position the recordset in the tabel with the appropriate select statement,
    and the use the Delete method of that recordset to delete the "current" record.

    Note : with Delete, you do NOT use the Update method.

    Arthur Wood

    "Matt Wyant" <MDWyant@SRPnet.com> wrote:
    >
    >It's me again.
    >
    >I have created a DAO 3.6 Access database program, and I need to know a couple
    >things.
    >
    >I need to be able to add and delete a record. I would like the new record
    >to be appended to the end of the database. And when I delete, I would like
    >it to be the current record.
    >
    >Any help would be appreciated, but please keep in mind that I am a very

    new
    >programmer and the more detailed the explanation the more helpgul it is.
    >
    >Thank you.
    >
    >Matt Wyant
    > MDWyant@SRPnet.com
    > Http://www.public.asu.edu/~Mwyant



  3. #3
    Matt Wyant Guest

    Re: More Database Questions


    Can you give me some small pieces of code that refelct what you are saying?
    Maybe just using one field. I think I have already created a recordset
    (I can browse the database, just not edit it).

    Matt Wyant
    MDWyant@SRPnet.com

    "Arthur Wood" <wooda@saic-trsc.com> wrote:
    >
    >in order to add a new record to the databse, you will create a recordset

    object
    >and open it with an SQL Select statement which will creatre all of the fields
    >to be populated. YOu will the use the AddNew method of the record set,

    populate
    >the fields with the new data values, and the save the record with the Update
    >method of the recordset. This will in fact insert that new record at the
    >"end of the table".
    >
    >When you delete a record, you create a recordset object,
    >position the recordset in the tabel with the appropriate select statement,
    >and the use the Delete method of that recordset to delete the "current"

    record.
    >
    >Note : with Delete, you do NOT use the Update method.
    >
    >Arthur Wood
    >
    >"Matt Wyant" <MDWyant@SRPnet.com> wrote:
    >>
    >>It's me again.
    >>
    >>I have created a DAO 3.6 Access database program, and I need to know a

    couple
    >>things.
    >>
    >>I need to be able to add and delete a record. I would like the new record
    >>to be appended to the end of the database. And when I delete, I would like
    >>it to be the current record.
    >>
    >>Any help would be appreciated, but please keep in mind that I am a very

    >new
    >>programmer and the more detailed the explanation the more helpgul it is.
    >>
    >>Thank you.
    >>
    >>Matt Wyant
    >> MDWyant@SRPnet.com
    >> Http://www.public.asu.edu/~Mwyant

    >



  4. #4
    Arthur Wood Guest

    Re: More Database Questions


    this is by way of an example, I have extracted this from an Access application
    that I developed at work:

    Dim dbs As Database
    Dim rsWorkUnit As Recordset
    Dim strSQL As String

    strSQL = "SELECT * FROM tblWorkUnit WHERE WU_ID = " & _ mudtProps.WU_ID

    Set dbs = CurrentDb()
    Set rsWorkUnit = dbs.OpenRecordset(strSQL)


    If mflgNew Then
    rsWorkUnit.AddNew
    rsWorkUnit!CreateDate = VBA.Now
    rsWorkUnit!ModifyBy = strUser
    Else
    rsWorkUnit.Edit
    rsWorkUnit!ChangeDate = VBA.Now
    rsWorkUnit!ModifyBy = strUser
    End If

    rsWorkUnit.Update

    If mflgNew Then mudtProps.WU_ID = rsWorkUnit.Fields("WU_ID")

    rsWorkUnit.Close

    you should also look at the Help for Recordset and then AddNew, Edit, UPdate
    and Delete methods.

    "Matt Wyant" <MDWyant@SSRPnet.com> wrote:
    >
    >Can you give me some small pieces of code that refelct what you are saying?
    > Maybe just using one field. I think I have already created a recordset
    >(I can browse the database, just not edit it).
    >
    >Matt Wyant
    > MDWyant@SRPnet.com
    >
    >"Arthur Wood" <wooda@saic-trsc.com> wrote:
    >>
    >>in order to add a new record to the databse, you will create a recordset

    >object
    >>and open it with an SQL Select statement which will creatre all of the

    fields
    >>to be populated. YOu will the use the AddNew method of the record set,

    >populate
    >>the fields with the new data values, and the save the record with the Update
    >>method of the recordset. This will in fact insert that new record at the
    >>"end of the table".
    >>
    >>When you delete a record, you create a recordset object,
    >>position the recordset in the tabel with the appropriate select statement,
    >>and the use the Delete method of that recordset to delete the "current"

    >record.
    >>
    >>Note : with Delete, you do NOT use the Update method.
    >>
    >>Arthur Wood
    >>
    >>"Matt Wyant" <MDWyant@SRPnet.com> wrote:
    >>>
    >>>It's me again.
    >>>
    >>>I have created a DAO 3.6 Access database program, and I need to know a

    >couple
    >>>things.
    >>>
    >>>I need to be able to add and delete a record. I would like the new record
    >>>to be appended to the end of the database. And when I delete, I would

    like
    >>>it to be the current record.
    >>>
    >>>Any help would be appreciated, but please keep in mind that I am a very

    >>new
    >>>programmer and the more detailed the explanation the more helpgul it is.
    >>>
    >>>Thank you.
    >>>
    >>>Matt Wyant
    >>> MDWyant@SRPnet.com
    >>> Http://www.public.asu.edu/~Mwyant

    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center