Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable "Delete" and "Edit" buttons on subform

Status
Not open for further replies.

kfrench

Technical User
Jan 17, 2002
2
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top