Results 1 to 3 of 3
  1. #1
    euphonium01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    40

    Deleting the current Record using OnClose Property

    If I close a Form and a control, [Serial #], is left blank (Null), what code in vb do I put in to delete the record that's currently showing? At the moment, my coding gives me the MsgBox stating that selecting Yes will delete the record, but it doesn't delete it, obviously I have that bit of coding wrong, the code I have written is attached to the Form's OnClose property. What I need is to select 'Yes', and the current record showing is deleted and a MsgBox confirms it's deleted successfully, or, if I select 'No' the Form does not close and a MsgBox says record not deleted. (The Form in question is called RSdata).

    That little bit of hair left on my head is getting less and less, any help will be appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    use queries for everything.
    make a delete query. usu you use the KeyID, but you can use =NULL

  3. #3
    euphonium01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    40
    Yep, ranman256 came up trumps again. Created the Delete Query, after a bit of 'adjusting' it worked a treat, problem solved. Thanks again ranman!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-15-2013, 12:30 PM
  2. Deleting current record using VBA
    By Kivan in forum Programming
    Replies: 3
    Last Post: 08-07-2012, 11:31 AM
  3. onclose event
    By imintrouble in forum Forms
    Replies: 14
    Last Post: 10-18-2011, 08:10 PM
  4. Deleting a record
    By alexc333 in forum Access
    Replies: 7
    Last Post: 07-26-2011, 10:43 AM
  5. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums