Use the Windows File Open/Save Common Dialogs
Problem
You need to allow users to choose filenames for opening and saving files. You know that Windows supports a common way to get these names. How can you use this mechanism from within Access?
Solution
Not only can you use the common File Open/Save dialogs, but you even have four ways to do it:
You can use the ActiveX control,
COMMDLG.OCX, that ships with the Office Developer’s Edition (ODE).You can call a function in
MSACCESS.EXE, which is how the wizards show the dialogs.You can call the Windows API directly.
In Access 2002, you can use the new FileDialog object.
If you don’t have the ODE, the first suggestion won’t help. The wizard interface for using these dialogs is a bit simpler than doing the work from scratch, but it’s also quite limiting (you get only a few options), and it isn’t available in runtime versions of Access 2000. The new FileDialog object in Access 2002 is available in the runtime environment, but it also limits your options. Therefore, this solution shows how to call the Windows API directly and lists all the options you have when using these common dialogs.
Open and run the form frmTestOpenSave from
04-08.MDB. This sample form allows you to set
various flags (described later in this solution) and to see the
results. You can try both the File Save and File Open common dialogs.
Try changing some of the settings and see what happens. Figure 4-16 shows the File Open dialog—with the Read Only checkbox ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access