Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a field F with values A, B, C, D.
I have Section Access applied:
User X can see only values A+D
User Y can see only values B+D
User Z can see only values C+D
I have a button;
on click field value A shall be selected for User X;
on click field value B shall be selected for User Y;
on click field value C shall be selected for User Z;
I know how to do this in a 'brute force' of coding, but my question is, whether there is a generic way (for much more value combinations and users).
The common case is, that I want to select the first entry in a sorted field value list.
Do you have any idea for an 'elegant' solution?
Thank you,
Thilo
Hi
With a macro you can do it: regards
sub selectFirstValue
set LB = ActiveDocument.GetSheetObject("LB01")
boxvalues=LB.GetPossibleValues
ActiveDocument.Fields("Fieldname"). Select boxvalues(0)
end sub
regards
/Fredrik
How about a table with User, Value?
Like
User Value
X A
X D
Y B
Y D
Z C
Z D
Does every user get a selection + D? Should the button always select the other value (not D)?
If so, field F should always have two values, the "select" value and D. When the user clicks the button, select both values (*) and then deselect (ToggleSelect) D.
Sub Selector
ActiveDocument.Fields("F").Select "*"
ActiveDocument.Fields("F").ToggleSelect "D"
End Sub
If it's not as simple as that, I'd make another table with user and select value as fields. You should have the user when they open the document, so you should be able to use this table to select the necessary values. EDIT: Or what Mark said, I didn't see his reply when I posted.
Hi
With a macro you can do it: regards
sub selectFirstValue
set LB = ActiveDocument.GetSheetObject("LB01")
boxvalues=LB.GetPossibleValues
ActiveDocument.Fields("Fieldname"). Select boxvalues(0)
end sub
regards
/Fredrik
NMiller wrote:Does every user get a selection + D?
No, it was just meant to show that there are more values in the field than I have users.
I am afraid of the table-solution (by Mark), as this means continued maintennace work.
My sample is very simplified. In reality I have a number fields which need special treatment and many users.
fredrik.martzen wrote:ActiveDocument.Fields("Fieldname"). Select boxvalues(0)
So if my list is sorted (I assume that this can also be forced within the macro), this would be it.
Thank you!
And just out of curiosity: A generic (i.e. no manual data assignment necessary) solution without macro (so just by the means of QV-Formala/Script) in sight?