I have a continuous form in Access with Allow Additions
set to Yes
. I'm trying to enable or disable a deletion button depending on if the user has filled in data in that record. In other words, I want to hide the button for only the blank record at the bottom of the form.
I tried the following in the Form_Current event but it enables or disables all buttons at the same time, and it only runs when I click on a record. I need it to run immediately and update when I add a new row.
If Me.NewRecord Then
btnDelete.Visible = False
Else
btnDelete.Visible = True
End If
EDIT: with working code.
If Me.NewRecord Then
'show error message
MsgBox ("Unable to delete empty row.")
Else
'deletion code
End If
Continuous forms won't allow that - everything looks the same.
You might be able to add code to the btnDelete_Click
event that checks for Me.NewRecord
and just exits the sub