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

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.
wlwebbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
"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
wlwebbAuthor Commented:
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
Jeffrey CoachmanMIS LiasonCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

wlwebbAuthor Commented:
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
Jeffrey CoachmanMIS LiasonCommented:
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
wlwebbAuthor Commented:
Boag....

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

???????????????
0
Jeffrey CoachmanMIS LiasonCommented:
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
wlwebbAuthor Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MacroShadowCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.