Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Kampala, Uganda

    Question Unanswered: Was Cancel pressed in the SaveAs dialog box?

    I'm using the common controls dialog to display a save as dialog. I provide a default file name, and only want to save if the user presses Save, and not if they press Cancel. How do I know if they pressed cancel?

    Everything I look at uses the following sort of thing, but because I specified a file name first, the filename is never empty.
    CommonDialog1.Filter = "Excel Workbook (*.xls)|*.xls"
    CommonDialog1.FileName = strDefaultExportFileName

    If CommonDialog1.FileName <> "" Then
    strFileName = CommonDialog1.FileName
    'Do the saving...
    End If

  2. #2
    Join Date
    Sep 2003
    Caldes de Malavella, Spain
    You don't say what version of Access you are using, but if I were you I'd use the FileDialog object in Access XP/2003 (not sure about 2000). It has a .Show property that will be true or false depending on whether the user pressed OK or Cancel. Using the CommonDialog will not allow you to detect the Cancel if you have a default file name, as you say, and there's no other way. Hope this helps.
    Andy Briggs
    Elmhurst Solutions Limited
    Database Development and Consultancy

Posting Permissions

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