Hello,
I have a form with a subform in it. On the subform I have Add, Delete, and Edit buttons which add or remove entries to the subforms table. What I'd like to do is set it up to disable the "Delete" and "Edit" buttons on the subform if there are not records.
I seem to have the enable/disable portion working. The problem is that after deleting the final record it gives me an error of "No Record" when I attempt to add a record or change to a new record on the main form.
I've place the following code in the subforms OnLoad, OnCurrent and AfterDelete events.
If (Me.Recordset.RecordCount = 0) Then
cmdEditHistory.Enabled = False
cmdDeleteHistory.Enabled = False
Else
cmdEditHistory.Enabled = True
cmdDeleteHistory.Enabled = True
End If
If I remove this code from all three it works great except that the delete and edit buttons are still enabled. If it's in ANY of the three I get the message. I thought at first that it might have been the OnCurrent since it may be trying to reference an undefined record but that didn't help.
Thanks,
Keith
I have a form with a subform in it. On the subform I have Add, Delete, and Edit buttons which add or remove entries to the subforms table. What I'd like to do is set it up to disable the "Delete" and "Edit" buttons on the subform if there are not records.
I seem to have the enable/disable portion working. The problem is that after deleting the final record it gives me an error of "No Record" when I attempt to add a record or change to a new record on the main form.
I've place the following code in the subforms OnLoad, OnCurrent and AfterDelete events.
If (Me.Recordset.RecordCount = 0) Then
cmdEditHistory.Enabled = False
cmdDeleteHistory.Enabled = False
Else
cmdEditHistory.Enabled = True
cmdDeleteHistory.Enabled = True
End If
If I remove this code from all three it works great except that the delete and edit buttons are still enabled. If it's in ANY of the three I get the message. I thought at first that it might have been the OnCurrent since it may be trying to reference an undefined record but that didn't help.
Thanks,
Keith