jwcolby
jwcolby at colbyconsulting.com
Sat Apr 23 08:51:18 CDT 2011
Darrell,
This is one of those misleading error messages. Every single open query or or table uses a
"database". This means every combo box (uses a query to display the data), bound form, bound
report, open recordset and so forth.
The usual villain is a bound form with bound subforms with dozens of combo boxes open.
I investigated this extensively a few years ago and what I discovered is that Access has some magic
number which is the maximum number of recordsets available to the application. It seems that the
number was somewhere around 1800. Every time you opened a query (combo, report, sub-report etc) the
number available dropped. When you got low enough (and "low enough was not zero) you started
getting this error.
There is no fix, this is a "by design" limitation. You work around it by using JIT subforms and the
like to minimize the number of objects using queries.
BTW, you can discover for yourself what this number is fairly easily but there is no place (that I
could discover) that you could go to see how many were left.
The following code is not pretty but it does the job. In my case I am getting only 408 recordsets.
I could swear the number was much higher. this is against linked SQL Server databases so maybe
that has something to do with it. If we could get a bunch of people to run the code and report back
their numbers that would help us to see better.
Function rstOpen(db As DAO.Database, intTheLimit As Integer) As DAO.Recordset
Dim rst As DAO.Recordset
On Error Resume Next
Set rst = db.OpenRecordset("SELECT * from tblLocation", dbOpenSnapshot, dbSeeChanges)
If Err Then
MsgBox intTheLimit & " is the max number of recordsets you can open"
Else
Set rstOpen = rst
End If
End Function
Function TestTheLimit()
Dim db As DAO.Database
Dim col As Collection
Dim intTheLimit As Integer
Set db = CurrentDb
Set col = New Collection
On Error Resume Next
While True
intTheLimit = intTheLimit + 1
col.Add rstOpen(db, intTheLimit)
Debug.Print intTheLimit
DoEvents
Wend
End Function
John W. Colby
www.ColbyConsulting.com
On 4/23/2011 8:20 AM, Darrell Burns wrote:
> Howdy. First-time on AccessD.
>
> I've tried all the other forums and can't get an answer to this one.
>
> I have a FE A2007 app linked to a BE A2007 database. There's a master form
> with 6 tabs. Each tab contains a subform that's bound to a query. Plus I
> open recordsets on the the BE tables to fetch stuff for the form. You can
> drill down from any subform to a detailed form by double-clicking a data
> field. I started getting the above error message after opening 2 or 3 of
> these forms, so I created a form handler method that shuts down the calling
> form and closes all the DB connections before opening the target form. I'm
> still getting that error. I've gone thru my code and diligently set all DBs
> to nothing at the end of each sub, but I can't seem to lick the problem.
>
>
>
> Suggestions from other forums have been to unbind the tables from the
> subforms. I buy that, but the question I can't get an answer to is how can I
> monitor how many connections I have open at one time so I can diagnose the
> problem? I feel like I'm debugging in the dark.
>
>
>
> Please turn on the light for me.
>
>
>
> Thanx,
>
> Darrell
>
>
>
>
>