Error - Cannot open any more databases...

J

Jim Burke in Novi

I am getting runtime error 3048 - Cannot open any more databases. I have a
form that has several combo boxes and I added some logic that causes them to
be requeried in certain cases. I never got this error before I made this
change, so I'm pretty sure that's what caused me to start getting this error.
I searched in the microsoft knowledge base and couldn't get any hits on this
error message or error number.
 
A

Allen Browne

Each combo box has a RowSource, which has a connection to the "database", so
too many combos can trigger this problem. I would not expect to see the
problem unless you have many scores of combos though. I don't know if
constantly requerying the combos will trigger the issue: if so, Access is
not releasing the database connections correctly.

Are all these combos using the same RowSource? For example, in a rostering
application you might have lots of timeslots on screen, and a combo for
selecting a person for each slot, all the combos get their RowSource from
the Employee table. If so, it may be possible to solve the problem by
changing the RowSourceType of all the combos to a callback function where
the data is held in a static array. These things are somewhat cryptic (but
not difficult), and it sounds like you you will also need to provide the
functionality to Redim the static array if you are constantly requerying. It
solves the problem because all combos are loaded from the one array instead
of Access holding a separate Recordset for each one, with its attendant
database connection.

There's a rudimentary example of a callback function in Method 2 of this
article:
List Box of Available Reports
at:
http://allenbrowne.com/ser-19.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
T

TC

This error will also occur if you try to open too many recordsets (not
databases). My guess is, that you have caused a loop of some kind in
your code, to cause this to happen. The requery is probably part of it.
If you judiciously disable code, bit by bit, you should be able to find
the cause. You can "disable" code by temporarily enclosing it with "if
false then" ... "endif".

And - more to the point - what is the line of code on which the error
occurs?

HTH,
TC [MVP Access]
 
J

Jim Burke in Novi

I do have some common rowsources, so that may be the solution. I think I also
may have some recordsets I open and never explicitly close, so I need to look
at that too. Thanks much for the reply.
 
J

Jim Burke in Novi

I think you're both on to something. Allen's suggestion will help, since I do
have common rowsources, and I also may be leaving some recordsets open, so I
need to go back and make sure I close them in all instances. Thanks for
replying.
 
J

Jim Burke in Novi

I don't think the line of code is really relevant - it's just a DLookup using
a query as the 'record source'. I think the problem is that when it tries to
open that query to do the lookup it's at the max number of recordsets, or
whatever it is it's maxing out on. I haven't touched the code that does that
DLookup in some time. The problem started when I added some logic to do
re-queries for the rowsources of some combo boxes. Before that I had the
rowsource set for the comboboxes to a query and they were never requeried.
For each combobox in question, in certain cases I now do a combobox.requery.
That's what started my problem. Is there a way to tell it to free something
up when I do the requeries?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top