|
I was calling the Sub from the Open event.
Still haven't figured out what the substantive difference is between Load and
Open, but I tried calling from the Load event, with no luck.
I also took a look at the References. Visual
Basic for Applications and Microsoft Access 8.0 Object Library were the top two
and were immovable. DAO library was 3rd above a couple others that were
checked. So I couldn't move the DAO library up. I tried unchecking
and then rechecking, again no luck.
However, I did finally find a
workaround.
The best I can figure is that Access 97 does not
make Module functions available to be run from DAO queries by the time the
startup form's Load event is ran. As I said before, I got the error
when running code using the starup form, but as soon as the database was
open, I could run the same code that opened a query that used a function just
fine.
To work around this apparent bug or limitation, I
used the Timer event. In my Load event, I set TimerInterval = 500 and then
called the Sub that opens the query that uses the module function from the Timer
event (and set TimerInterval back to 0 so it would re-run the code every 1/2
second). Everything is golden now.
Thanks,
Toby
----- Original Message -----
Sent: Tuesday, January 17, 2006 2:40
PM
Subject: [AccessDevelopers] Re: Error
running query with function automatically
Toby, Are you calling the
function from the Open event or the Load event of your form? If you are
running from the Open event I suggest trying the Load event.
You might want to take a look in
your References under Tools|References in your code module. Sometimes the
order in which different libraries load can cause this problem. Ensure that
your DAO or ADO library are higher than the rest (except Visual Basic For
Applications that is). Basically, find the library, select it and use the
upward arrow button on the right of the dialog to take it as high as it will
go. If another library is loading first then your DAO/ADO information will not
be loaded properly when the form calls the function.
Hope that helps. ![]()
Bueno!
Duane Hennessy. Bandicoot
Software Tropical Queensland, Australia (ABN: 33 682 969 957)
Why recode
the wheel? http://www.bandicootsoftware.com.au
--- In [email protected], "Toby Bierly"
<[EMAIL PROTECTED]> wrote: > > Can anyone explain to me why I get an
error trying to open a select query into a recordset in code automatically run
upon startup of the database when the select query and the code that opens the
select query works just fine once the database is open?! > > I'm
really getting frustrated with this one. > > I have a startup
form that calls a Sub procedure. I have narrowed the Sub down to the
following: > > Sub testrst() > Dim rst As Recordset !
> Set rst = CurrentDb.OpenRecordset("qry_UnaddedJobs") > MsgB ox
"done" > End Sub > > If I open the database,
qry_UnaddedJobs works just fine and the testrst Sub runs just fine. But when I
call testrst from the startup form, I get the following error: >
> Run-time error '3085': > Undefined function 'yy_year' in
_expression_. > > Now 'yy_year' in one of a couple functions
defined in a Module that the query uses. If I edit the query not to call
yy_year, then the same error occurs on the other function that that query
uses. > > Again, I know the functions work fine because the query
uses them just fine once the database is open! > > Am I losing my
mind?? > > Any help will be appreciated. > >
Thanks, >
Toby >
Please zip all files prior to uploading to Files section.
YAHOO! GROUPS LINKS
|