Results 1 to 9 of 9
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    cannot open anymore databases (there ought not be that many open?)

    my code runs without issue; EXCEPT that at the end of it, i get the error: "cannot open anymore data bases"

    although it ought not to matter, there are
    ...146 records in tbeFixtureTypeDetails
    and


    ...114 records in tbeSubmittalDetails

    (learn something new every day... I'm lost on this one.)

    any suggestions would be appreciated in advance,
    best, stay well,
    m.

    Code:
    Public Sub SubmtlStatusSmry()
        On Error GoTo Err_SmtlTypeStatusSmry
        Dim dbs As Database
        Dim rst As DAO.Recordset
        Dim rst1 As DAO.Recordset
        Dim intDetail_Cnt As Integer
        Dim intTypeSubmtl_Cnt As Integer
        Dim vMAX_ID As Integer
     
        CurrentDb.Execute ("DELETE * FROM tbeSubmittalDetailSmry_temp")
        
        intDetail_Cnt = DCount("*", "tbeSubmittalDetails")
        If intDetail_Cnt > 0 Then
            Set dbs = CurrentDb
            Set rst = _
                dbs.OpenRecordset("SELECT * " & _
                "FROM tbeFixtureTypeDetails WHERE NOT void", _
                dbOpenDynaset)
            With rst
                DoCmd.GoToRecord , "", acFirst
                Do Until .EOF
                    intTypeSubmtl_Cnt = DCount("*", "tbeSubmittalDetails", "type = '" & rst!Type & "'")
                    If intTypeSubmtl_Cnt > 0 Then
                        Set rst1 = Nothing
                        Set rst1 = dbs.OpenRecordset("SELECT * FROM tbeSubmittalDetails WHERE type = '" & rst!Type & "' ORDER BY SubmittalID DESC")
                        vMAX_ID = rst1!SubmittalID
                        'add the type
                        CurrentDb.Execute _
                            "INSERT INTO tbeSubmittalDetailSmry_temp " & _
                            "(Type, SubmittalID, Action) " & _
                            "SELECT Type, SubmittalID, Action FROM tbeSubmittalDetails WHERE Type = '" & rst!Type & "' AND SubmittalID = " & vMAX_ID
                        rst1.Close
                        Set rst1 = Nothing
                    Else
                        ' add code for "no SUBMITTAL yet Received"
                    End If
                    .MoveNext
                Loop
            End With
    
            'housekeeping
            rst.Close
            dbs.Close
            Set rst = Nothing
            Set dbs = Nothing
        Else
            MsgBox "There are no entries to summarize"
        End If
    
        
    
    Exit_SmtlTypeStatusSmry:
        Exit Sub
    
    Err_SmtlTypeStatusSmry:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SmtlTypeStatusSmry, line " & Erl & "."
        Resume Exit_SmtlTypeStatusSmry:
    
    End Sub

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Have you had a look on google. I believe that fault is often caused by having an infinite loop.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    That is one of the more unhelpful error messages and often means you have run out of available connections due to having too many databases objects and recordsets open.
    Have a look at my app (adapted from an idea originally by Ben Sacharich) which monitors this. It may help.
    See http://www.mendipdatasystems.co.uk/a...ons/4594418530
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    This will be interesting to know how many recordsets show up. I notice that this
    Set rst1 = Nothing
    is done at the end AND the beginning of the loop. Rather than continually creating and destroying recordsets I would have tried creating it once but SET it to a new set of data on each loop. Not sure if that would make a difference (or even if that works), but when we see something like this, sometimes it's because pc speeds are too fast and as a result, we see situations where code lines don't get processed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    I changed the middle of the code to be (see below); getting rid of the rst1, and replacing with dMax() - which gets me to where i wanted to be and is probably what i ought have used in the first place).

    ...still stuck

    Code:
    With rst
                DoCmd.GoToRecord , "", acLast
                DoCmd.GoToRecord , "", acFirst
                Do Until .EOF
                    'check if there are any submittals for this type
                    intTypeSubmtl_Cnt = DCount("*", "tbeSubmittalDetails", "type = '" & rst!Type & "'")
                    If intTypeSubmtl_Cnt > 0 Then
                        'determine the most recent for the type
                        vLastSubmittalID = DMax("[SubmittalID]", "tbeSubmittalDetails", "[type] = '" & rst!Type & "'")
                        'add the type
                        CurrentDb.Execute _
                            "INSERT INTO tbeSubmittalDetailSmry_temp " & _
                            "(Type, SubmittalID, Action) " & _
                            "SELECT Type, SubmittalID, Action FROM tbeSubmittalDetails WHERE Type = '" & rst!Type & "' AND SubmittalID = " & vLastSubmittalID
                    Else
                        ' add code for "no SUBMITTAL yet Received"
                    End If
                    .MoveNext
                Loop
    End With

  6. #6
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    well....
    if you're creating the reports' data while you're in the report (vs. before the report)
    (.... there's where the problem was)

    "if the problem is persistently not where you expect it to be ...look somewhere else"
    problem solved

    thnx,
    m

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Code:
    With rst
                DoCmd.GoToRecord , "", acLast
                DoCmd.GoToRecord , "", acFirstUsually just
    Usually it's just
    With rs
    .MoveLast
    .MoveFirst

    and it's not even necessary to do that unless you need the record count.
    However, if the rs contains no records, you will raise an error either way. Better (?)
    If Not (rs.EOF And rs.BOF) Then 'if both, then there are no records
    Do Until rs.EOF
    ...
    Last edited by Micron; 05-14-2020 at 05:34 PM. Reason: correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    officially now: my "best tip gotten May 2020" !!!

    big thnx

  9. #9
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Apparently you have a field name of "Type".
    Be aware that "Type" is a reserved word in Access and shouldn't be used for object names.


    Code:
    Set rst = _            
    dbs.OpenRecordset("SELECT * " & _            
    "FROM tbeFixtureTypeDetails WHERE NOT void", _            
    dbOpenDynaset)
    I also question the use of "VOID" in the where clause.


    Maybe you meant
    Code:
    WHERE NOT IsNULL(SomeFieldName)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recursion and recordsets (too many databases open)
    By mcucino in forum Programming
    Replies: 11
    Last Post: 10-01-2019, 06:13 PM
  2. Replies: 23
    Last Post: 05-02-2018, 07:11 PM
  3. Open Multiple Databases
    By neuroman in forum Modules
    Replies: 1
    Last Post: 03-06-2016, 10:25 PM
  4. Cannot open any more databases.
    By evander in forum Queries
    Replies: 7
    Last Post: 08-24-2010, 12:22 AM
  5. Cannot open any more databases error
    By Matthieu in forum Access
    Replies: 2
    Last Post: 04-14-2010, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums