Peter Peterson
Member
- Local time
- Tomorrow, 02:48
- Joined
- Sep 14, 2020
- Messages
- 38
Good evening,
I know what I am trying to achieve, however, the theory using VBA has the better of me.
I have a Form, "frmClinetBrowser" with a subForm, "subfrmClientList" (data grid of Client information, "dshClientList") which allows the user to browse the list of Clients (see attached).
I have replaced the standard navigation buttons with my own which are on the Form (not the subForm).
I have an on_click event for each button which works. e.g.
I have code in Form_Current sub which does not work.
The code is designed to "disable" First and Previous command buttons if at Record 1. and "disable" Last and Next command buttons if at last Record.
I have a separate command button, New which will open a new form to enter a new clients information.
The Code below is for records in the Form, not the subForm - borrowed from an example I found.
My problem is I don't understand the VBA theory to access the correct information in the subForm from the Form to disable the relevant navigation buttons.
I encounter an error "You entered an expression that has an invalid reference to the property CurrentRecord" which I assume is related to my overall problem.
I hope I have explained myself clearly and someone can assist me.
Thanking you
Peter
I know what I am trying to achieve, however, the theory using VBA has the better of me.
I have a Form, "frmClinetBrowser" with a subForm, "subfrmClientList" (data grid of Client information, "dshClientList") which allows the user to browse the list of Clients (see attached).
I have replaced the standard navigation buttons with my own which are on the Form (not the subForm).
I have an on_click event for each button which works. e.g.
Code:
Private Sub btnNext_Click()
On Error GoTo Err_btnNext_Click
Forms![frmClientBrowser]![dshClientList].SetFocus
DoCmd.GoToRecord , , acNext
Exit_btnNext_Click:
Exit Sub
Err_btnNext_Click:
MsgBox Err.Description
Resume Exit_btnNext_Click
End Sub
I have code in Form_Current sub which does not work.
The code is designed to "disable" First and Previous command buttons if at Record 1. and "disable" Last and Next command buttons if at last Record.
I have a separate command button, New which will open a new form to enter a new clients information.
The Code below is for records in the Form, not the subForm - borrowed from an example I found.
My problem is I don't understand the VBA theory to access the correct information in the subForm from the Form to disable the relevant navigation buttons.
Code:
Private Sub Form_Current()
On Error GoTo Err_Form_Current
If Me.CurrentRecord = 1 Then
Me.btnFirst.Enabled = False
Me.btnPrevious.Enabled = False
Else
Me.btnFirst.Enabled = True
Me.btnPrevious.Enabled = True
End If
If Me.CurrentRecord = Me.Recordset.RecordCount Then
Me.btnLast.Enabled = False
Else
Me.btnLast.Enabled = True
End If
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
Me.btnNext.Enabled = False
Else
Me.btnNext.Enabled = True
End If
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
I hope I have explained myself clearly and someone can assist me.
Thanking you
Peter