+ Reply to Thread
Results 1 to 5 of 5

Clearing table contents when closing Access?

  1. #1
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    137

    Clearing table contents when closing Access?

    Hello,

    I do not understand why this macro is not deleting my table's contents when exiting Access or even closing the form. Since I have multiple forms, how is this code suppose to work if my main form gets closed?

    Thanks!!!

    HTML Code: 
    Private Sub Form_Close()
    Dim tbl As TableDef
    Dim sqlstr As String
        DoCmd.SetWarnings False
            sqlstr = "DELETE * FROM tbl_dateReferences"
            DoCmd.RunSQL sqlstr
        DoCmd.SetWarnings True
    End Sub

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 2019
    Posts
    16,496

    Re: Clearing table contents when closing Access?

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    137

    Re: Clearing table contents when closing Access?

    Unfortunately, it did not work. I corrected the typo in the code and still did not work. I guess Access does not have the same functionality as Excel.

    Thanks.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 2019
    Posts
    16,496

    Re: Clearing table contents when closing Access?

    Works in my DB. Without seeing your DB, can not offer any further assistance.

  5. #5
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    137

    Re: Clearing table contents when closing Access?

    This is a sample file. Table includes a set of default dates. If dates are changed in form, it adds a new date row in table. I need to wipe any entries and return to default dates when re-opening the file. I have included a module with your code to prove that it was not working.


    THanks again for your help!!!!
    Attached Files Attached Files
    Last edited by icyrius; 01-15-2020 at 01:15 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1