Results 1 to 5 of 5
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    VB to Turn off Notifications

    Trying to run this query to create a table which would be a backup copy of my table from the current database, but create the copy in another database. I want to run this automatically on my formclose() event.....




    Code:
       Dim db As Database  
       Set db = CurrentDb  
       DoCmd.SetWarnings False  
       db.Execute "qryBackupTable", dbFailOnError  
       Set db = Nothing  
       DoCmd.SetWarnings True




    But I get an error table already exists, how to overwrite table so this error does not occur?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    According to your code you are working with Currentdb.
    What is the query sql? How are you accessing/connecting/linking to the
    "other" database?

    You could open the "other" database" and check if a particular table exists or not.
    You could run sql to delete the table in the "other database", and if it isn't there, just continue on.


    Good luck

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I just used the prompts when building the query to make a table, and it said make table in current database or another database, and I selected my other database. It has no problem making the table, but once the table is there, it can not overwrite it w/o human intervention (at least with the current code).

    How would I use SQL to delete the table in the manner you are referencing?
    Or could I set it in the VBA of my onclose() event like I am trying to work with?
    This may not even be possible, but say something like,
    if tbl.backuptable = true then
    docmd.delete backuptable
    end if


    Or maybe not?!

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    have you tried copying the first table and then deleting it when the make table op is done??

    you can use DOCMD's for that. in addition, you can set a string variable to:
    Code:
    db.TableDefs(tblName).name
    with 'tblName' being the name of the table that either exists or not. check the ERR.NUMBER property after that. if it's 3265, the table does not exist.

    or better yet, if the thing doesn't error out, the table is probably already there.

  5. #5
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I just changed my query from a make table query to an append query. Then I set a delete query to run 1st to delete the entries on the table, and then my append query runs, to append the data to the table.

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

Similar Threads

  1. Turn off Navigation Pane
    By newtoAccess in forum Access
    Replies: 9
    Last Post: 08-01-2011, 11:32 AM
  2. sound notifications
    By TheShabz in forum Access
    Replies: 7
    Last Post: 08-31-2010, 08:54 PM
  3. Turn warnings off
    By Mclaren in forum Programming
    Replies: 6
    Last Post: 05-03-2010, 12:07 PM
  4. Replies: 5
    Last Post: 01-29-2010, 11:09 AM
  5. Turn Off Auto Save Record
    By Syntinal in forum Forms
    Replies: 2
    Last Post: 03-01-2009, 11:30 AM

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