Please see attached screen shot. As you can see I have a main form (DPR_Main) with a subform (DPR_Survey). Within the subform is another subform (DPR_Resources) .
I am using the following code I grabbed off the interwebs for the unbound textbox (called txtRecordNo) that acts as a record count:
I have this on all three forms.
For the three nav buttons I have the following code (again on all three forms):
The next buttons work great on the Cultural Resources section and the DPR (main) section. On the Survey section I get an error that says "Run-time error '3201': No current record." When I debug it highlights the .MoveFirst or sometimes the.MoveLast part of the first code section posted above.
The Add New button works only on the Cultural Resources section. The Previous button works fine.
What am I doing wrong? I mean, besides trying to hack together code I don't fully understand that is.
I am using MS2007 but saving as an 03 mdb, as that will be what our field crews will be running.
I am using the following code I grabbed off the interwebs for the unbound textbox (called txtRecordNo) that acts as a record count:
Code:
Private Sub Form_Current()
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
End Sub
For the three nav buttons I have the following code (again on all three forms):
Code:
Public Sub Next_Record()
On Error GoTo Err_Next_Record
With Recordset
If .AbsolutePosition = .RecordCount - 1 Then
'you are on the last record
DoCmd.GoToRecord , , acFirst
Else
'you are on some other record
DoCmd.GoToRecord , , acNext
End If
End With
Exit_Next_Record:
Exit Sub
Err_Next_Record:
MsgBox Err.Description
Resume Exit_Next_Record
End Sub
-------------------------------
Private Sub cmdAdd_Click()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cmdNext_Click()
Call Next_Record
End Sub
------------------------------
Private Sub cmdPrevious_Click()
If Me.CurrentRecord > 1 Then
DoCmd.GoToRecord , , acPrevious
Else
MsgBox "You are at the first record!", vbOKOnly, "Warning!"
End If
End Sub
The Add New button works only on the Cultural Resources section. The Previous button works fine.
What am I doing wrong? I mean, besides trying to hack together code I don't fully understand that is.
I am using MS2007 but saving as an 03 mdb, as that will be what our field crews will be running.
Comment