check box to alter form properties

John thomas

Registered User.
Local time
Today, 05:31
Joined
Sep 4, 2012
Messages
206
Hi i have a form called Orders.I need to lock this form once an invoice has been printed
I have a check box on this form ,that if ticked should lock that specif order
This is my Code

Private Sub Form_Open(Cancel As Integer)
If Me.lockorder = True Then
Me.AllowEdits = False
End If
End Sub

The problem is it does nothing .
I am using the open event of the form .The checkbox is called LockOrder

Thank you
 
It could be because it expect -1 instead of True.
Code:
If Me.lockorder = -1 Then
Else try to move it to the OnCurrent event.
I suppose Me.lockorder controlsource is bound to a field in form's recordsource?
 
when the form open event is run, data has not been loaded so if your code is referring to a field value it will not return anything

the earliest opening function you can use where data is present is the load event

the current event is triggered later when a record has the focus
 
Is the checkbox bound to a field in the table? If so, you might want to trigger this setting to be applied for every record, and then you want to use the Current event of the form.

And, this code only does anything if LockOrder is true.
Code:
Private Sub Form_Open(Cancel As Integer)
   If Me.lockorder = True Then 
      Me.AllowEdits = False
   End If
End Sub
If it is false, the reverse setting should be applied, but your code doesn't address that. Consider code like this . . .

Code:
private sub form_current()
[COLOR="Green"]   'whether or not edits are allowed varies directly with 
   'whether the item is locked
[/COLOR]   Me.AllowEdits = Not Me.LockOrder
end sub
Hope this helps,
 
Thanks to all .The on current event was the problem .but i have taken yhe other comments onboard
John
 

Users who are viewing this thread

Back
Top Bottom