Form On Current event

Dan25e

Registered User.
Local time
Today, 00:02
Joined
Dec 3, 2014
Messages
33
Hi Peeps,

I'm trying to lock certain fields on my form based on the value in a particular field. It seems to work the first time but applies itself to all other records in the database from then on!

The starting point is a command button that sends an email and makes Me.DPLLock = 1. The corresponding table entry is formatted as a number.

The code I'm pulling my hair out over is...

Private Sub Form_Current()

If Me.DPLLock = 1 Then
Me.OR_Name.Locked = True
Me.OR_Sales_Order.Locked = True
Me.OR_WO_No.Locked = True
Me.OR_Qty.Locked = True
Me.OR_Dept.Locked = True
Me.OR_Project.Locked = True
Me.OR_Part_No.Locked = True
Me.OR_Part_Iss.Locked = True
Me.OR_Drg_Iss.Locked = True
Me.OR_Query.Locked = True
End If

Ive tried Me!DPLLock with the same result. :banghead:

Forgive the underscores in the field names, I did them when I was an even smaller puppy!

Any pointers?
 
What do you want to happen?
Tell us about the Form-- bound? Continuous?
 
If the value in DPLLock is 1, lock all the fields listed in in the On Current event.

As far as I can see the form is bound as each of the fields are linked to a table and it displays one record at a time.
 
OK, so you have a bound form with a single record view.

Is it possible that all records have DPLLock = 1?
 
No. I have a temporary field on the form that displays the DPLLock field so I can see that when the email is sent the value is being added. The records that have not had the email sent are all empty.
 
is it possible to add new hidden textbox on your form and on the click of email button save the recordnum , id, or name of the current record, then you can test:

If Me.DPLLock = 1 and txtBoxRecordNumber = Me.ID Then
' do the lock
 
It's looking like one way to do it is on the On Current event set all the fields to .Locked = False and then do the lock...
 
It locks the controls because you told it to. So the controlsremain locked until someone unlocks them.

Code:
If some_condition then
   lock the lot
else
   unlock the lot
end if
 

Users who are viewing this thread

Back
Top Bottom