Results 1 to 4 of 4
  1. #1
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55

    Question Clicking on a dialog box with VBA

    I am writing some VBA to import data from an excel file. The seudo code looks like:

    Copy "tablename" table to "tablename-backup"
    Delete contents of "tablename"


    Import contents of Excel file into the blank "tablename"

    To run the backup I am using DoCmd.CopyObject, "tablename-backup", acTable, "tablename"

    Works great on initial run but once the table is created I am getting a "Do you want to overwrite" dialog pop up box on subsequent runs.

    How can I write the code for:

    IF dialog popup box, slecet "Yes"?

    Thanks!

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Not aware of any way to do this, but in code you can turn off these warnings temporarily by using this code:

    Code:
    DoCmd.SetWarnings False  'Turn warnings off
       'Code here to do whatever is throwing up the warning
    DoCmd.SetWarnings True    'Turn warnings back on

    Be sure to turn them back on after the triggering event. There may be times when you want to know when Access is going to do something; it may be something you didn't intend!

    Linq ;0)>

  3. #3
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55
    Quote Originally Posted by Missinglinq View Post
    Not aware of any way to do this, but in code you can turn off these warnings temporarily by using this code:

    Code:
    DoCmd.SetWarnings False  'Turn warnings off
       'Code here to do whatever is throwing up the warning
    DoCmd.SetWarnings True    'Turn warnings back on

    Be sure to turn them back on after the triggering event. There may be times when you want to know when Access is going to do something; it may be something you didn't intend!

    Linq ;0)>
    Thank you, this worked like a charm.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

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

Similar Threads

  1. Scrolling to the top on clicking a tab
    By Hasher in forum Forms
    Replies: 4
    Last Post: 05-12-2013, 07:38 PM
  2. Replies: 7
    Last Post: 12-17-2011, 08:06 PM
  3. Comments when clicking a button
    By Juan4412 in forum Programming
    Replies: 4
    Last Post: 06-23-2011, 04:34 PM
  4. Clicking links in webpages
    By dssrun in forum Programming
    Replies: 5
    Last Post: 01-16-2011, 09:04 PM
  5. Clicking on label opens up new record
    By swimmermx in forum Forms
    Replies: 2
    Last Post: 07-20-2010, 03:58 PM

Tags for this Thread

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