I am using the following code I grabbed off the interwebs for the unbound textbox (called txtRecordNo) that acts as a record count:
Expand|Select|Wrap|Line Numbers
- 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):
Expand|Select|Wrap|Line Numbers
- 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.