Enabling /Locking controls on a continuous form

SalmonDB

Registered User.
Local time
Today, 06:24
Joined
Dec 5, 2012
Messages
17
Hello, I'm having some trouble writing code to lock/disable controls after a certain event.

Basically, I have a button 'cmdPrint' that brings up and fills in an excel sheet with a bunch of labels for sample vials with unique sample numbers. At the same time, when ever the print button is clicked, another control 'DatePrinted' is automatically filled in so I know when I printed that collection of labels.

This is on a continuous form, and I would like to stop users from deleting or editing a record after the labels have been printed.

First, for the delete button (each record on the form includes a delete button) I wrote the following code
Code:
Private Sub Form_Current()
If Not IsNull(DatePrinted) Then
Me.cmdDelete.Enabled = False
End If
End Sub
This almost works, but it disabled the Delete button for every record on the form, not just the ones with a 'date printed'. I suspect there is something I'm missing about event procedures for a continuous form.

I also tried the following:
Code:
Private Sub DatePrinted_AfterUpdate()
If Not IsNull(DatePrinted) Then
Me.cmdDelete.Enabled = False
End If
End Sub
This didn't seem to do anything at all. I could still delete records after a date had been entered.

I would also like to lock the other controls in the record (ex. Vial Numbers, etc) once there is a date entered, but I presume I will have the same problems.

Any suggestions would be much appreciated.

Thanks!
Erica
 
Try:
Code:
Private Sub Form_Current()
If Not IsNull(DatePrinted) Then
  Me.cmdDelete.Enabled = False
Else
  Me.cmdDelete.Enabled = True
End If
End Sub
 
Aha, works great now, thanks Bob!
 

Users who are viewing this thread

Back
Top Bottom