Hi,
I has the On Open action for my Form set to:
Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount < 1 Then
Me.Command33.Enabled = False
Else
Me.Command33.Enabled = True
End If
End Sub
which works fine, unless I delete all the records shown on the form. Why, because the button sends and email based on the data on the form and it cannot be allowed to send an empty email. I can add code to the on_click action that checks and displays a msgbox if there are no records but that looked a bit untidy, far better to disable the button if the are no records.
So I added and after_update event similar to the code shown above.
All works fine as I said unless I delete all the records (the button does disable) and then when I click on my close button :
Private Sub Close_Button_Click()
On Error GoTo Err_Close_Button_Click
DoCmd.Close
DoCmd.OpenForm "Master"
Exit_Close_Button_Click:
Exit Sub
Err_Close_Button_Click:
MsgBox Err.Description
Resume Exit_Close_Button_Click
End Sub
I get a 'No Current Record' error box, when I hit OK the form closes. If I remove the On_Open event it doesn't error when closing.
Where am I going wrong.
Thanks,
John
I has the On Open action for my Form set to:
Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount < 1 Then
Me.Command33.Enabled = False
Else
Me.Command33.Enabled = True
End If
End Sub
which works fine, unless I delete all the records shown on the form. Why, because the button sends and email based on the data on the form and it cannot be allowed to send an empty email. I can add code to the on_click action that checks and displays a msgbox if there are no records but that looked a bit untidy, far better to disable the button if the are no records.
So I added and after_update event similar to the code shown above.
All works fine as I said unless I delete all the records (the button does disable) and then when I click on my close button :
Private Sub Close_Button_Click()
On Error GoTo Err_Close_Button_Click
DoCmd.Close
DoCmd.OpenForm "Master"
Exit_Close_Button_Click:
Exit Sub
Err_Close_Button_Click:
MsgBox Err.Description
Resume Exit_Close_Button_Click
End Sub
I get a 'No Current Record' error box, when I hit OK the form closes. If I remove the On_Open event it doesn't error when closing.
Where am I going wrong.
Thanks,
John