Results 1 to 3 of 3
  1. #1
    Join Date
    May 2016
    Posts
    9
    Provided Answers: 1

    Unanswered: delete table on exit

    Hey everyone, please excuse me if i use any wrong terms as i am still learning how to creating things in access. I created a database that it meant only to print notification flyers and when you close it I have it set to delete the table. Everything works as it should except for when someone closes the database without typing anything in. I get a run time error. I'm pretty sure it is because my code it trying to delete something that is not there. I think i need to add a If isnull statement in the code to stop it so doesn't error if there is no records to delete, but i just don't know how/where to add it. Also I am using access 2010 64 bit.

    Any help is greatly appreciated.


    This is the code that i am using i have it set on a hidden form that loads at start.

    Code:
    Private Sub Form_Unload(Cancel As Integer)
    Dim dbs As dao.Database
    Dim rst As dao.Recordset
    
    Set dbs = CurrentDb
    
    Set rst = dbs.OpenRecordset("bolo_tbl")
    rst.Delete
    End Sub

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So set an error handler
    Trap the error and take appropriate action.
    Or just be a cowboy and ignore the error by using
    Code:
    on error resume next
    But make certain you ckear the error handler afterwards
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2016
    Posts
    89
    Provided Answers: 4
    Hi
    try : set rst = nothing

Posting Permissions

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