Results 1 to 7 of 7

Thread: Delete Record

  1. #1
    Join Date
    Nov 2009
    Posts
    223

    Unanswered: Delete Record

    Code:
    Private Sub cmdDeleteRecord_Click()
    Dim rst As DAO.Recordset
        
        If MsgBox("Are you sure you wish to delete this record? It cannot be undone?", vbYesNo + vbInformation, "Please confirm:") = vbYes Then
            Set rst = Me.Parent.Recordset
            If Not rst.EOF Then
                rst.Delete
                rst.MoveNext
            End If
            Set rst = Nothing
        End If
    End Sub
    I have been using this code from Access 2003 database in a command button to delete a record. I have copied and pasted my whole database into Access 2010.

    Please could I ask if this code is clean, up-to-date and still valid?
    I mean, it works, but are all the code still used in current practice?

    Hope you understand what i am trying to say?

    Cheers.
    What would you attempt to do if you knew you would not fail?

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    you might want to take out the dao.recordset and just try recordset in the dim statement. Also you said it does not work - what is the error message that is given?
    Dale Houston, TX

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by axsprog View Post

    ...you said it does not work...
    Sorry, but the OP said it did work!
    Quote Originally Posted by reddevil1 View Post

    ...I mean, it works...
    There's nothing wrong with this code; if it's working as you need it to, leave it alone!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Nov 2009
    Posts
    223
    Yup, the code DOES work.

    It is just that I have now started to redo the database in Access 2010 and I read that some older code in 2003 (and 2007) may not be compatible and some coding may not work in future updates?

    So, at this stage, I just wanted to take the opportunity to insert the latest coding?
    What would you attempt to do if you knew you would not fail?

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    DAO has supposedly been on the 'to die' list for quite a while (at least 13 years), but its still current.
    if it moves to deprecated then thats the time to start worrying
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by healdem View Post

    ...DAO has supposedly been on the 'to die' list for quite a while...
    Sure, just like VB6 was supposed to 'die' when VB.Net came out!

    The truth, reddevil1, is that it is very, very, very seldom that old code doesn't run in newer versions of Access. The real problem arises (frequently, but not always) when trying to move backwards in time! Developing an app in 2007 or 2010 and then trying to get it to run on pre-2007 Access can be problematic. Actually, even moving backwards from 2010 to 2007 can be trouble. The problems involve new things that aren't available in older versions, not vice versa.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Nov 2009
    Posts
    223
    healdem and linq,

    thanks for sharing your knowledge and advice about the 'old' code.

    i will act accordingly.

    have a great 2013 guys and keep up the great work.
    What would you attempt to do if you knew you would not fail?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •