Kevin said:
I've installed the code in a library, and it works. The
new FileDialog method, however, is "sticky"--the dialog
opens up in the last selected folder--while the API
routine starts at the top of the hierarchy each time.
I'd like to run the new method if the user is running
2002. I haven't been able to find how to access the
version programmatically. Have you done this with your
diverse user group?
Thanks. Best regards.
The Open/Save dialog will normally open in the "current" directory, and
unless told otherwise (as the code provided does by specifying the
option ahtOFN_NOCHANGEDIR) will change the current directory to the one
containing the selected file. So by leaving out that option you can
make the Open/Save dialog "sticky".
I may be wrong, but I think the BrowseFolder dialog can only be made
"sticky" by specifying a callback function, which I seem to recall an
example for doing on one of the MVP VB pages; maybe VBNet (
http://www.mvps.org/vbnet/ ) ... ah, yes:
http://www.mvps.org/vbnet/code/callback/browsecallbackoverview.htm
and
http://www.mvps.org/vbnet/code/callback/browsecallback.htm
So that may be an option if you want to keep your code
version-nonspecific.
You can tell which version of Access you're running by checking the
value returned by SysCmd(acSysCmdAccessVer). Access 2002 is version
"10.0", 2000 is version "9.0", and 97 is "8.0". Note that the value
returned is a string representation of a number, so if you want to
compare values you have to convert them to integers first.
However, I don't think knowing this is going to help you much in
deciding at run time whether or not to call Application.FileDialog,
because you'll have compilation and reference errors if you're running
the wrong Access version. What I do is have separate versions of a
module named basVersionDependent, and put all version-dependent code in
there. All the public functions defined in this module have the same
names, but the implementation is different depending on which version of
Access is being targeted. That way, I just swap in the appropriate
module when building the application for a specific Access version. The
Access-97 version of this module also contains my own implementation of
the VBA functions that were introduced in Access 2000, so that I can use
them in all versions of may application. The A2K version of this module
doesn't include my user-defined implementations, so the builtin
functions get called.