Hello I am having a little trouble with my database. The Database has a parent table with 5 or 6 children tables in it they are linked by a common id filed.
The problem is that the children tables use a VBA to display there Record number in a text box. The code works fine when they are displayed alone when I do not have them displayed in the main or parent table. The problem I get is "run-time error '3021' "
Here is the code I put in to the children's table under forms, events, form_Current.
The output is displeased in a unbound text box called txtRecordNo.
I have found two older threads that deal with this issue but I could I get the same run-time error message "run-time error '3021' "
here is the code of the older threads. the code is linked to in unbound label called RecNum.
I do not know how to deal with a run-time error '3021'. So if some one has a suggestion on how do get this code to work or a different way of displaying the records in a sub form.
The problem is that the children tables use a VBA to display there Record number in a text box. The code works fine when they are displayed alone when I do not have them displayed in the main or parent table. The problem I get is "run-time error '3021' "
Here is the code I put in to the children's table under forms, events, form_Current.
The output is displeased in a unbound text box called txtRecordNo.
Code:
Dim rst As DAO.Recordset
Dim lngCount As Long
Set rst = Me.RecordsetClone
With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With
Me.txtRecordNo = "Record " & Me.CurrentRecord & " of " & lngCount
I have found two older threads that deal with this issue but I could I get the same run-time error message "run-time error '3021' "
here is the code of the older threads. the code is linked to in unbound label called RecNum.
Code:
Option Compare Database
Option Explicit
Dim Records As DAO.Recordset
Dim TotalRecords
Private Sub Form_Load()
Set Records = Me.RecordsetClone
Records.MoveLast
TotalRecords = Records.RecordCount
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![RecNum].Caption = TotalRecords + 1 & " pending..."
End Sub
Private Sub Form_AfterInsert()
Records.MoveLast
TotalRecords = Records.RecordCount
End Sub
Private Sub Form_Current()
If Not Me.NewRecord Then
Records.Bookmark = Me.Bookmark
Me![RecNum].Caption = "Record " & _
Records.AbsolutePosition + 1 & " of " & _
TotalRecords
Else
Me![RecNum].Caption = "New Record"
End If
End Sub
I do not know how to deal with a run-time error '3021'. So if some one has a suggestion on how do get this code to work or a different way of displaying the records in a sub form.