Function not defined

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've found some code samples I'm trying to use to display a dialog box for
the user to select a file for importation. The samples use ahtAddFilterItem
and ahtCommonFileOpenSave, but when I try to run the code I get a complile
error that these functions are not defined. I have the following references
checked: VBA, Access 11.0 Objects, DAO 3.6, ADO 2.1, VBA Extensibility 5.3,
Office 11.0 Objects.

Do I need to check another reference? Or is there some other thing I need
to do/include to access these functions?
 
They sound like functions from the File Open/Save Dialog Box API at the MVP
site (and maybe elsewhere). The code for the functions needs to be included
in the form's code module. That is to say, there is code that starts
"Function ahtAddFilterItem(strFilter As String, _
strDescription As String, Optional varItem As Variant) As String
or something like that. The code from there to the next End Function needs
to be pasted into the form's code module. The same goes for another
function that starts with "Function ahtCommonFileOpenSave".

Couldn't you just link to the file? That would be simpler, I think. What
do you mean when you say you are trying to import it?
 
Ah! The posts and examples I saw didn't make any references to the source
so I was assuming they were part of a standard library. I'll go try to find
the function code and that oughta help.

The file I'd like to import is a monthly financial report, in Excel format,
from another (non-DB/Access) application. It'll be used, after a little
massaging, to update existing records in my new Access application. Since
it's a monthly activity I'm trying to automate as much of it as possible.
For development at the moment I'm using a fixed location & file name. But
for long term use, I figure a month is long enough between updates to forget
what this is for naming the file before running the update. Seems like a
better idea to let the person go find the file they just created. That's
what I was looking for examples of.

-Karen
 
Ah. You want to import the data. Now I get it. I think you will need
something like the API to open the dialog box, then.
 
Yep. I found the source where I copied the original snippet; the functions
were at the bottom of the page: http://www.mvps.org/access/api/api0001.htm.

But I plunked it in my form module and I've got a whole bunch of 'red lines'
on the global definitions. When I run it anyway, it gives an error that
Constants aren't allowed as Public members of object modules.

-Karen
 
I have to tell you that I recognized the cause of the situation, but I don't
fully understand what is needed. There unfortunately is not much
documentation on the mvps web site for this sort of thing.

It may be that the code needs to be in a standard module separate from the
form's code module, but I am not certain of what is needed after that. It
may be best to start a new thread if nobody jumps into this one. Specify
that you are trying to open the Open/Save dialog box.
 
You got it. It hit me shortly after replying to try it in it's own module.
It's working fine now.

Thanks for your help!

-Karen
 
Back
Top