Selecting only the filled controls

Pusher

BEOGRAD Put
Local time
Today, 17:51
Joined
May 25, 2011
Messages
230
Hi all,
I need your help with partial locking of a record. This is the situation when there is a shift change and one record is started by one person and finished by another. What one has written another can’t change but must finished a record. So u must lock only the combo boxes and text boxes that are filled. This code lockes all the combo boxes and text boxes and 2 check boxes (NEZAVRSENE_INTERVENCIJE and IZMENA_RASKRSNICE) by clicking on a NEZAVRSENE_INTERVENCIJE check box. Lets say I have combo boxes 1 2 and 3 and text boxes 1 2 and 3 and I have to lock only the ones that are filled. How do I code that another check box lockes just the filled controls?

Thanks
Code:
Private Sub NEZAVRSENE_INTERVENCIJE_AfterUpdate()
Dim ctrl As Control

If Me.NEZAVRSENE_INTERVENCIJE = -1 Then

For Each ctrl In Me.Controls
   
    If (TypeOf ctrl Is TextBox) Or (ctrl Is NEZAVRSENE_INTERVENCIJE) Or  (ctrl Is IZMENA_RASKRSNICE) Or (TypeOf ctrl Is ComboBox) Then
     ctrl.Locked = True
  
    End If
 Next

Else

For Each ctrl In Me.Controls
   
   If (TypeOf ctrl Is TextBox) Or (ctrl Is NEZAVRSENE_INTERVENCIJE) Or  (ctrl Is IZMENA_RASKRSNICE) Or (TypeOf ctrl Is ComboBox) Then
      ctrl.Locked = False

    End If
 Next
 
End If
End Sub
 
If I understand your post correctly:
  • In Form Design View, hold down <Shift> and click on each Control that you want Locked to select it.
  • Right Click and select Properties
  • Go to "Other"
  • In the last box, labeled Tag Property, enter LockIfFilled
Now, in code
Code:
Private Sub Form_Current()

Dim ctrl As Control

If Me.NEZAVRSENE_INTERVENCIJE = -1 Then

For Each ctrl In Me.Controls
    
  If ctrl.Tag = "LockIfFilled" Then
   If Nz(ctrl, "") <> "" Then
    ctrl.Locked = True
   Else
    ctrl.Locked = False
   End If
  End If

Next

End If

End Sub


Private Sub
Code:
NEZAVRSENE_INTERVENCIJE_AfterUpdate()

Dim ctrl As Control

If Me.NEZAVRSENE_INTERVENCIJE = -1 Then

For Each ctrl In Me.Controls
    
  If ctrl.Tag = "LockIfFilled" Then
   If Nz(ctrl, "") <> "" Then
    ctrl.Locked = True
   Else
    ctrl.Locked = False
   End If
  End If

Next

End If

End Sub
Linq ;0)>
 
Last edited:
You are a GOD :)
Thanks !
 

Users who are viewing this thread

Back
Top Bottom