Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Lock a field in vb script

Hi,

I try to lock a field using: ActiveDocument.Fields("myField").Lock OR ActiveDocument.GetField("myField").Lock

without success. Do i make a mistake?

If i look the property CanLoc: ActiveDocument.Fields("myField").Canlock the result is false

How can i enable this?

           

in more if i look ActiveDocument.Fields("myField").GetLocked() OR ActiveDocument.Fields("myField").IsLocked

it's false

3 Replies
Gysbert_Wassenaar

Make sure one or more values are selected in the field. Otherwise you can't lock the field.


talk is cheap, supply exceeds demand
Not applicable
Author

There are no possibility to lock a field without value selected?

I need to lock the fields because the user can't select a value as there are a lot of field to lock i use a vb script

sub lockTESTFields

   

    set flddescs = ActiveDocument.GetFieldDescriptions

    for i = 0 to flddescs.count -1

        fdesc = flddescs(i)

        if InStr(1,fdesc.Name,"CCA")>0 then

            'fdesc.Lock

            ActiveDocument.Fields(fdesc.Name).Lock

           

            temp=ActiveDocument.Fields(fdesc.Name).CanLock

'msgbox fdesc.Name&" "&temp

           

            'MsgBox ActiveDocument.Fields(fdesc.Name).GetLocked()

            if fdesc.IsLocked then

                MsgBox "ok=="&fdesc.Name

            'else

                'MsgBox "NOK=="&fdesc.Name

            end if

        end if

    next

end sub

Not applicable
Author

if i load all the possible values for every field, i'm out of memory so my alternative is to lock every fiel one per one in parameter -> trigger at the open of the document