Solved

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

Posted on 2014-07-27
9
33 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
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

832 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