Solved

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

Posted on 2014-07-27
9
36 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 85
ID: 40223881
"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
ID: 40224080
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
ID: 40225291
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:wlwebb
ID: 40225311
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40225359
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
ID: 40229929
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
ID: 40230721
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
ID: 40265983
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 27

Expert Comment

by:MacroShadow
ID: 41640936
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

690 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