Solved

Access 07 - Subforms static number of records selected with DAO.recordset - Error cycling back to first subform

Posted on 2014-07-27
9
31 Views
Last Modified: 2016-06-07
Hello Experts....

I have a form that has 4 subforms.  The subforms use Parent/Child link to bring the correct number of records up.  That part works fine.

On each subform I have an unbound textbox called [txtWaitEnd] that when the that textbox has the focus I execute the following (ALL THE SUBFORMS HAVE THIS SAME UNBOUND TEXTBOX and VBCode):
Private Sub txtWaitEnd_GotFocus()
Dim strSQL As String
Dim rs As DAO.Recordset
Dim a As Long, b As Long, c As Long

a = Me.LVLInfoID

strSQL = "SELECT LVLInfoDtailID, LVLInfoID, LVLMachPollPositionID From tbl_LVLInfoDetails WHERE LVLInfoID=" & a
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
        If rs.RecordCount > 0 Then
            rs.MoveLast
            rs.MoveFirst
            b = rs.RecordCount
            With rs
                .FindFirst "[LVLMachPollPositionID] = " & Me.LVLMachPollPositionID
                If .AbsolutePosition = b - 1 Then
                    Parent.[sfrm_LVLInfoDetails_AmtOut].SetFocus
                Else
                End If
            End With
        End If

rs.Close
Set rs = Nothing

End Sub

Open in new window


This works right to cycle thru all of the records on each subform and if it's the last record for that subform then it goes to the next subform etc....

However, the problem is when I get to the last record of the 4th subform.  When the txtWaitEnd gets the focus I get the error:
'Run-time error '3048':
Cannot open any more databases.
I don't understand why I'd get this since in each subform I'm "closing" and setting each DAO.recordset to Nothing at the end of every vb instruction.
0
Comment
Question by:wlwebb
9 Comments
 
LVL 84
Comment Utility
"Cannot open any more databases" does not only deal with items YOU open, but also with open connections for controls and such. For example, each Combo or Listbox creates an "open database" connection that can impact the number of open databases, as well as each Subform, etc etc. Access handles this internally so there's no way to "reset" it or anything of that nature.

That said: what the code is supposed to do? If you just want to move to the last record in each subform, use the MoveLast command:

Me.SubformControl1.Form.Recordset.MoveLast

From what I can see, it just cycles through the records and (apparently) moves to different subforms when the code is finished. What's the reason for doing that?
0
 

Author Comment

by:wlwebb
Comment Utility
I am wanting it to cycle thru each of the records in AmtA then go to the subform to input AmtB, then AmtC then AmtD.

Here is a stripped down version.  Note that I have code that initializes so that it pre-sets up a record for each active MachNbr.  Those records all get initialized with a zero amt and then the clerk inputs but can't add or delete records.

Note: when you cycle thru all of them and finish subform AmtD that's where it hits the error.
EE-CycleSubforms.accdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
wlwebb,

No offense, ...but you have not answered Scott's question(s):
From what I can see, it just cycles through the records and (apparently) moves to different subforms when the code is finished. What's the reason for doing that?

Neither have I had a need for doing anything like this, ...so again, can you explain fully the need for doing this, ...
Perhaps there is a simpler way to get you what you are after...

JeffCoachman
0
 

Author Comment

by:wlwebb
Comment Utility
The reason for doing it that way is because of the way the data is produced and comes into the clerk and from which the clerk must enter.  AmtA is on one Doc... AmtB is on another Doc etc....

The entity has no control and can not change how that data is supplied..... Nor can the data be imported.  It has to be keyed.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Then please post the explicit steps to recreate the error.

I did not get the error you reported, ...I got this instead:
my error
0
 

Author Comment

by:wlwebb
Comment Utility
Boag....

I have tried recreating my original error.....
Now all I am getting is the same one you posted
Run-time error '2110'

???????????????
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
I am still not understanding why you need to do this.

Why cant this just be 4 simple subforms?

In other words, ...give us a step by step scenario of what the data entry person need to do, and why...
0
 

Accepted Solution

by:
wlwebb earned 0 total points
Comment Utility
Figured out the problem myself.   The error was resulting from the sequencing of when it was going to the next tabstop.

The solution was to have
txtWait  - Tabstop 0
TransAmt - Tabstop 1
txtWaitEnd - Tabstop 2

Then have txtWaitEnd 's TabStop set to "Inactive" until txtwait's record number equals form's recordset.recordcount then make txtWaitEnd 's tabstop "active"

Then in txtWaitEnd movefirst
0
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: wlwebb (http:#a40265983)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now