Deleting a record from a table.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jruffino@nsls.info

    Deleting a record from a table.

    Hi,

    I am writing code for a project I am working on using Accewss 2000, and
    when I choose an item from a drop-down box, I want to delete it form
    the table it is getting the info from.

    I am using the following code:

    'Dim dbGiant As Database
    'Dim rsGiant As Recordset

    'Set dbMyDB = OpenDatabase("G iants_Sign-UP.mdb")
    'Set dbGiant = CurrentDb()
    'Set rsGiant = dbGiant.OpenRec ordSet("school_ all", dbOpenDynaset)

    'If Not rsGiant.EOF Then rsGiant.MoveFir st
    'Do While Not rsGiant.EOF
    'lstRecords.Add Item rsMyRS!Name
    'lstRecords.Ite mData(lstRecord s.NewIndex) = rsMyRS!ID
    ' If Me!cmb_session_ date.Value = rsGiant!school_ name Then
    ' Debug.Print "Match"
    ' rsGiant.MoveNex t
    'Loop

    But, everytime I invoke it, I come up with the following error when I
    have the first 2 lines uncommented:

    Complie Error: User-defined type not defined

    Now, I wil admit I learned Access using 97, and this is 2000, and I am
    not full up on the new way of 2000. But, I have an older project that
    I converted to use with 2000, and have almost the same code, and that
    works.

    Another qustion, excuse my naivity, but when I do help, it gives me
    this code, which I fully understand, and other code using OCDBC.

    If someone can help me either point to a place to help me understand
    this, or just help me to an understanding of how the NEW Access works?

    Joe R.

  • lylefair@yahoo.ca

    #2
    Re: Deleting a record from a table.

    Access 2000 defaults to ADO.

    If you want to use DAO then be sure there is a DAO reference in your
    references and qualify your objects as
    DAO.DataBase
    DAO.Recordset
    ****
    I would use ADO as follows

    Dim rsGiant as ADODB.Recordset

    Set rsGiant=Current Project.Connect ion.Execute("Sc hool_All")
    (assuming School_All is a query)

    or
    Set rsGiant=Current Project.Connect ion.Execute("SE LECT * FROM
    School_All")
    (assuming School_All is a table or view)

    With rsGiant
    While Not .EOF
    ... whatever
    .MoveNext
    Loop

    This has several fewer lines than DAO and does nor require the release
    of the recordset variable. You should be aware that the code presented
    is untested "air code" and may have syntax errors and that many
    regulars here are committed to using DAO only for Access-JET. I never
    use DAO in code (although Access may).

    Comment

    • pietlinden@hotmail.com

      #3
      Re: Deleting a record from a table.

      I know this is hijacking a topic (shame on me!), but what's the most
      useful resource you've come across to learn ADO? I started learning it
      when it just came out, and the documentation was so bad that I just
      used DAO instead. Much easier to find info on...

      I guess any resources would be good... David Fenton said that Chipman &
      Baron's book on Access/SQL Server was really good. Are there any
      others that you know of? IIRC, David Sussman wrote one for Wrox that
      was supposed to be okay...

      any ideas/opinions? And which books are *terrible*? (Won't waste my
      time looking at them then!)

      Thanks,
      Pieter

      Comment

      Working...