04-20-04, 05:29 #1Registered User
- Join Date
- Apr 2004
- Kampala, Uganda
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...
04-20-04, 12:47 #2Registered User
- 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