Peter Peterson
Member
- Local time
- Today, 21:51
- Joined
- Sep 14, 2020
- Messages
- 38
Hi,
Using Office 365 on latest OS - new to MS Access.
I have created a client browser window with a datasheet (sub-form) of clients (limited columns from table).
On the browser window I have added navigation buttons (as opposed to using the systems navigation toolbar).
I have written the code and tried a couple methods (not sure what I'm doing).
My initial code with no checking worked until I got an error when clicking 'next record" when at the last record.
I am trying to catch the error before it happens and now the next button does not work.
I suspect my issue is the record set does not have any relationship with the datasheet.
Any advice will be most welcome.
Using Office 365 on latest OS - new to MS Access.
I have created a client browser window with a datasheet (sub-form) of clients (limited columns from table).
On the browser window I have added navigation buttons (as opposed to using the systems navigation toolbar).
I have written the code and tried a couple methods (not sure what I'm doing).
My initial code with no checking worked until I got an error when clicking 'next record" when at the last record.
I am trying to catch the error before it happens and now the next button does not work.
I suspect my issue is the record set does not have any relationship with the datasheet.
Any advice will be most welcome.
Code:
Private Sub btnNext_Click()
Dim db As DAO.Database
Dim rstClients As Recordset
On Error GoTo Err_btnNext_Click
Set db = CurrentDb
Set rstClients = db.OpenRecordset("tblClients", dbOpenDynaset)
Me.dshClientList.SetFocus
' With rstClients
' If .AbsolutePosition = .RecordCount - 1 Then
' MsgBox "At last record"
' Else
' DoCmd.GoToRecord , , acNext
' End If
' End With
' If Not rstClients.EOF 'Then
rstClients.MoveNext
' End If
Me.Form.SetFocus
Exit_btnNext_Click:
Set rstClients = Nothing
Set db = Nothing
Exit Sub
Err_btnNext_Click:
MsgBox Err.Description
Resume Exit_btnNext_Click
End Sub