wlwebb
asked on
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):
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:
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
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.
Cannot open any more databases.
ASKER
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
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
wlwebb,
No offense, ...but you have not answered Scott's question(s):
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
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
ASKER
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.
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.
ASKER
Boag....
I have tried recreating my original error.....
Now all I am getting is the same one you posted
Run-time error '2110'
???????????????
I have tried recreating my original error.....
Now all I am getting is the same one you posted
Run-time error '2110'
???????????????
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...
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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.Re
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?